test(dsm): regression tests for DSM context leak between concurrent consumers#7580
test(dsm): regression tests for DSM context leak between concurrent consumers#7580robcarlan-datadog wants to merge 7 commits intomasterfrom
Conversation
…rrent consumers When two KafkaJS consumers process messages concurrently and each produces to a different topic, the DSM (Data Streams Monitoring) context leaks between them. The first consumer to process loses its DSM context entirely (null parent), while the second consumer picks up the first's context instead of its own. This test forces the interleaving by using promise gates to ensure both eachMessage handlers have fired before either produces, reliably reproducing the bug. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Overall package sizeSelf size: 4.69 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 816.75 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
BenchmarksBenchmark execution time: 2026-02-19 19:48:16 Comparing candidate commit 7f52edd in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7580 +/- ##
==========================================
- Coverage 80.29% 78.96% -1.33%
==========================================
Files 732 727 -5
Lines 31468 31207 -261
==========================================
- Hits 25267 24643 -624
- Misses 6201 6564 +363 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…mq, rhea, google-cloud-pubsub Same root cause as the kafkajs test: ctx.currentStore is set by startSpan before decodeDataStreamsContext/setCheckpoint call enterWith, so the DSM context is never included in the bound store for async continuations. Verified deterministic: 10/10 failures across all plugins and versions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c75ac65 to
ee7424d
Compare
Summary
dsm.spec.js), and google-cloud-pubsubRoot Cause
ctx.currentStoreis set bystartSpan()which snapshots the ALS store beforedecodeDataStreamsContext/setCheckpointcallenterWith()to set the DSM context. Afterstore.run()restores the prior store (with DSM context) to the outer context, the next consumer'sstartSpancaptures that leaked DSM context into its ownctx.currentStore, while the first consumer's callback has no DSM context at all.Test plan
🤖 Generated with Claude Code