Skip to content

test(rum): Fix flaky datadogRecorder worker cleanup - #5341

Open
thomas-lebeau wants to merge 1 commit into
mainfrom
dd/automation/thomas-lebeau/fix-recorder-worker-cleanup-87e6acea
Open

thomas-lebeau wants to merge 1 commit into
mainfrom
dd/automation/thomas-lebeau/fix-recorder-worker-cleanup-87e6acea

Conversation

@thomas-lebeau

Copy link
Copy Markdown
Collaborator

Motivation

Fixing startRecording > when calling stop() > stops collecting records • View in Test Optimization • Questions? Ask in #code-gen-flaky-tests

Test Optimization reports a 0.37% failure rate and three affected pipelines for startRecording > when calling stop() > stops collecting records. Recent sibling failures also report canvas-worker message listeners executing in the following test.

The original 15-second timeout did not reproduce locally. Telemetry and code-path analysis identified a concrete test cleanup leak: resetDeflateWorkerState removed lifecycle listeners and discarded worker references without terminating native workers. Capture-specific listeners could therefore still fire after cleanup. One historical listener trace is truncated in stored telemetry.

Refs: N/A

Changes

  • Terminate loading and initialized deflate/canvas workers in the shared test-only reset helper. All callers are specs; the failing test constructs its worker in setupStartRecording and calls this helper from its registered cleanup at packages/browser-rum/src/boot/datadogRecorder.spec.ts:75.
  • Use a fresh, unprocessed MockWorker for every initialization-timeout fixture creation. This avoids orphaning idle native workers when a timeout discards their state, and preserves distinct worker identities across resets.
  • Add regression coverage for cleanup of both worker names while loading and initialized. Both new cases fail against the original reset implementation.

This change is AI-generated. The connection between the confirmed cleanup leak and the rare standalone timeout is inferred; CI still needs to confirm that every reported timeout is resolved.

Test instructions

  • Full browser unit suite with CI console checks, Istanbul coverage, and seed 1819: 5,577 tests passed across 321 files.
  • Recorder suite: all 13 tests passed the initial execution plus 50 repeats with CI coverage. Worker suite: all 24 tests passed the initial execution plus 50 repeats.
  • Both new cleanup regressions failed against the original reset helper and passed with the fix.
  • yarn typecheck, scoped ESLint, and Prettier checks passed.
  • Local runs used a temporary config outside the repository to select installed Chromium revision 1247 because Playwright's requested revision 1255 was absent; other runner settings were preserved.
  • The original timeout did not reproduce locally.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

PR by Bits - View session in Datadog

Comment @DataDog to request changes

DD_GKTF7V

Co-authored-by: thomas-lebeau <1926949+thomas-lebeau@users.noreply.github.com>
@datadog-datadog-us1-prod

Copy link
Copy Markdown

View session in Datadog

Bits Code status: ✅ Done

CI Auto-fix: Disabled | Enable

Comment @DataDog to request changes

@thomas-lebeau
thomas-lebeau requested a review from a team as a code owner November 26, 2026 18:42
@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T18:43:07.174915Z 9f359d3 PR opened
🔒 Security Review ✅ Completed 2026-11-26T18:44:23.815201Z 9f359d3 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cit-pr-commenter-54b7da

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 194.46 KiB 194.46 KiB 0 B 0.00% ✅
Rum 194.44 KiB 194.44 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 8.10 KiB 8.10 KiB 0 B 0.00% ✅
Rum Profiler 8.10 KiB 8.10 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.21 KiB 60.21 KiB 0 B 0.00% ✅
Rum Slim 149.83 KiB 149.83 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 225.98 KiB 225.98 KiB 0 B 0.00% ✅
Rum Shopify Profiler 8.10 KiB 8.10 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅
Early Collection 309 B 309 B 0 B 0.00% ✅

@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 78.07% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9f359d3 | Docs | View more details | Give us feedback!

@datadog-datadog-us1-prod datadog-datadog-us1-prod Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bits Code Review: PASS

More details

Worker termination is consistent with the reset helper’s test-only callers, and the revised timeout fixtures preserve the unresponsive-worker scenario. The original rare recorder timeout remains unverified.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 9f359d3

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants