test(child_process): fix Bluebird flake that cascades to every later spec#9078
Conversation
Overall package sizeSelf size: 6.44 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.2.0 | 104.26 kB | 843.44 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9078 +/- ##
=======================================
Coverage 93.73% 93.73%
=======================================
Files 895 895
Lines 51398 51399 +1
Branches 11980 11980
=======================================
+ Hits 48178 48180 +2
+ Misses 3220 3219 -1 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BenchmarksBenchmark execution time: 2026-07-01 15:50:01 Comparing candidate commit 9e59a8f in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2255 metrics, 31 unstable metrics.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f90d86f4dd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
f90d86f to
4174e9d
Compare
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 9e59a8f | Docs | Datadog PR Page | Give us feedback! |
4174e9d to
2fe78d6
Compare
…spec
The Bluebird specs set global.Promise = Bluebird in beforeEach and restored it
only in afterEach, holding the mutation across the awaited span round-trip. Under
load the subprocess span arrives late, and the shared assertion helper only
rejects once a payload has already errored, so the spec hangs to mocha's 5 s
timeout while leftover async keeps global.Promise flipped, corrupting context for
every later spec in the file.
1. The instrumentation only reads global.Promise synchronously, when the wrapped
method runs. Scope the swap to that window via withBluebird() and restore it in
a finally before any await.
2. assert.strictEqual(promise.constructor, Bluebird) asserts a property that
depends on module-load order and the call-time global, not on any contract the
instrumentation makes; it held locally and on Node 18 but saw the native
constructor on Node 20. Assert the real contract instead: the promisified call
resolves with the expected stdout and still produces the span.
3. Await the span expectation and the subprocess completion together in one
Promise.all per spec, so a late or failed span cannot float onto the shared
agent and match a later spec's expectation.
Drive-by fix:
* Drop the dead `delete require.cache[require.resolve('util')]` (util is a builtin).
* Replace the try/catch rejection check with assert.rejects.
2fe78d6 to
9e59a8f
Compare
…spec (#9078) The Bluebird specs set global.Promise = Bluebird in beforeEach and restored it only in afterEach, holding the mutation across the awaited span round-trip. Under load the subprocess span arrives late, and the shared assertion helper only rejects once a payload has already errored, so the spec hangs to mocha's 5 s timeout while leftover async keeps global.Promise flipped, corrupting context for every later spec in the file. 1. The instrumentation only reads global.Promise synchronously, when the wrapped method runs. Scope the swap to that window via withBluebird() and restore it in a finally before any await. 2. assert.strictEqual(promise.constructor, Bluebird) asserts a property that depends on module-load order and the call-time global, not on any contract the instrumentation makes; it held locally and on Node 18 but saw the native constructor on Node 20. Assert the real contract instead: the promisified call resolves with the expected stdout and still produces the span. 3. Await the span expectation and the subprocess completion together in one Promise.all per spec, so a late or failed span cannot float onto the shared agent and match a later spec's expectation. Drive-by fix: * Drop the dead `delete require.cache[require.resolve('util')]` (util is a builtin). * Replace the try/catch rejection check with assert.rejects.
…spec (#9078) The Bluebird specs set global.Promise = Bluebird in beforeEach and restored it only in afterEach, holding the mutation across the awaited span round-trip. Under load the subprocess span arrives late, and the shared assertion helper only rejects once a payload has already errored, so the spec hangs to mocha's 5 s timeout while leftover async keeps global.Promise flipped, corrupting context for every later spec in the file. 1. The instrumentation only reads global.Promise synchronously, when the wrapped method runs. Scope the swap to that window via withBluebird() and restore it in a finally before any await. 2. assert.strictEqual(promise.constructor, Bluebird) asserts a property that depends on module-load order and the call-time global, not on any contract the instrumentation makes; it held locally and on Node 18 but saw the native constructor on Node 20. Assert the real contract instead: the promisified call resolves with the expected stdout and still produces the span. 3. Await the span expectation and the subprocess completion together in one Promise.all per spec, so a late or failed span cannot float onto the shared agent and match a later spec's expectation. Drive-by fix: * Drop the dead `delete require.cache[require.resolve('util')]` (util is a builtin). * Replace the try/catch rejection check with assert.rejects.
…spec (#9078) The Bluebird specs set global.Promise = Bluebird in beforeEach and restored it only in afterEach, holding the mutation across the awaited span round-trip. Under load the subprocess span arrives late, and the shared assertion helper only rejects once a payload has already errored, so the spec hangs to mocha's 5 s timeout while leftover async keeps global.Promise flipped, corrupting context for every later spec in the file. 1. The instrumentation only reads global.Promise synchronously, when the wrapped method runs. Scope the swap to that window via withBluebird() and restore it in a finally before any await. 2. assert.strictEqual(promise.constructor, Bluebird) asserts a property that depends on module-load order and the call-time global, not on any contract the instrumentation makes; it held locally and on Node 18 but saw the native constructor on Node 20. Assert the real contract instead: the promisified call resolves with the expected stdout and still produces the span. 3. Await the span expectation and the subprocess completion together in one Promise.all per spec, so a late or failed span cannot float onto the shared agent and match a later spec's expectation. Drive-by fix: * Drop the dead `delete require.cache[require.resolve('util')]` (util is a builtin). * Replace the try/catch rejection check with assert.rejects.
Summary
The Bluebird specs set
global.Promise = BluebirdinbeforeEachand restoredit only in
afterEach, holding the mutation across the awaited span round-trip.Under load the subprocess span arrives late, and the shared assertion helper only
rejects once a payload has already errored, so the spec hangs to mocha's 5 s
timeout. Meanwhile leftover async keeps
global.Promiseflipped, corruptingcontext for every later spec in the file — one slow span became 47 failures.
The instrumentation only reads
global.Promisesynchronously, when the wrappedmethod runs. The fix scopes the swap to that window via
withBluebird()andrestores it in a
finallybefore anyawait.Drive-by
delete require.cache[require.resolve('util')](util is a builtin).assert.rejects.