fix(test-optimization): stabilize failed test replay waits#9193
Conversation
Overall package sizeSelf size: 6.59 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.0 | 117.14 kB | 432.47 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 |
🎉 All green!🧪 All tests passed 🔄 Datadog auto-retried 2 jobs - 0 passed on retry 🎯 Code Coverage (details) 🔗 Commit SHA: ef99102 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-07 08:05:11 Comparing candidate commit ef99102 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2243 metrics, 43 unstable metrics.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9193 +/- ##
==========================================
- Coverage 93.55% 93.48% -0.08%
==========================================
Files 900 901 +1
Lines 52941 53307 +366
Branches 12491 12581 +90
==========================================
+ Hits 49531 49834 +303
- Misses 3410 3473 +63
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:
|
|
@codex review |
|
/datadog autotest review |
There was a problem hiding this comment.
More details
All 16 adversarial scenarios across the new DI-wait promise lifecycle (prepareDiBreakpointHitWait/cancelDiBreakpointHitWait/waitForDiBreakpointHits) and the worker drain mechanism passed. The mocha hookUp shimmer's missing return is intentional — Mocha's retry progression is callback-driven, not return-value-driven, so deferring the completion callback via .then() correctly pauses the test lifecycle until the probe is set. The worker drain ordering guarantee (snapshot in try, drain response in finally, FIFO MessageChannel) ensures all snapshots are attached before spans are closed.
📊 Validated against 16 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit 60949d1 · What is Autotest? · Any feedback? Reach out in #autotest
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 60949d19ad
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
60949d1 to
3f24425
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f24425add
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
3f24425 to
ff294e5
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff294e5915
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ff294e5 to
fef5e93
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fef5e93cae
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
fef5e93 to
fb5eadf
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb5eadf1db
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
fb5eadf to
4193f27
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4193f27355
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
4193f27 to
b08c469
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b08c469095
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b08c469 to
58d705b
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4b0922819
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1e9c05c03
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f1e9c05c03
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2bb152f434
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
More details
All 13 scenarios executed against real code paths — drain mechanism, withTimeout timeout/cancel/resolve ordering, prepareDiBreakpointHitWait multi-call state cleanup, removeEmptyCollectionProperties depth, and the full waitForPreparedDiBreakpointHit/cancel/timeout cycle. No behavioral regression found. The replacement of fixed setTimeout grace periods with DI-aware async waits is mechanically sound: the snapshot message always arrives on the channel before the drain acknowledgment (same breakpointHitChannel, ordered delivery), so finish() is never called before the snapshot is attached to the active test span.
📊 Validated against 13 scenarios · Open Bits AI session
🤖 Datadog Autotest · Commit 63c2b0c · What is Autotest? · Any feedback? Reach out in #autotest
What does this PR do?
Stabilizes Failed Test Replay across Jest, Vitest, Mocha, and Cucumber by replacing fixed grace-period waits and busy waits with DI-aware async waits. The shared CI plugin now prepares a bounded wait for the next breakpoint hit, can drain in-flight DI worker hits, and cancels unused waits when tests finish.
For Mocha, the retry hook wrapper is installed lazily only when Failed Test Replay and test dynamic instrumentation are enabled, so non-FTR runs avoid the extra wrapper path.
For Cucumber, Failed Test Replay DI waits are supported only when the runner exposes an awaited retry boundary. Older runners that only expose the envelope fallback intentionally skip DI probe setup instead of reintroducing a synchronous wait; this shortens FTR coverage for that Cucumber path and is an accepted tradeoff.
Motivation
The old implementation relied on fixed delays after failed attempts and, in some frameworks, synchronous busy waits before retries. That made replay timing race-prone: a breakpoint hit could arrive after the retried test span had already finished, losing the snapshot.