[Bug]: Long lived OTel traces with startStalledCheckTimer
Version
v5.81.4
Platform
NodeJS
What happened?
Worker.startStalledCheckTimer() schedules the infinite stalledChecker() loop inside an OpenTelemetry trace() callback. Because Node's AsyncLocalStorage (used by @opentelemetry/context-async-hooks, the default context manager) binds the active context to any async continuations scheduled inside the callback, the startStalledCheckTimer span's context becomes permanently attached to the checker loop.
Every stalled-check tick (default 30s) then creates a child span under that leaked context, appending to the same traceId for the entire lifetime of the worker.
How to reproduce.
This is from a nestjs api using @nestjs/bullmq and bullmq-otel. Using the standard setup to apply the telemetry to queues.
Relevant code: https://github.com/taskforcesh/bullmq/blob/master/src/classes/worker.ts#L1350
Relevant log output
Code of Conduct
- I agree to follow this project's Code of Conduct
Source: taskforcesh/bullmq