Skip to content

test(debugger): enforce teardown process isolation#7660

Merged
tlhunter merged 2 commits intomasterfrom
watson/flaky-fix2
Mar 4, 2026
Merged

test(debugger): enforce teardown process isolation#7660
tlhunter merged 2 commits intomasterfrom
watson/flaky-fix2

Conversation

@watson
Copy link
Copy Markdown
Collaborator

@watson watson commented Mar 4, 2026

What does this PR do?

It hardens debugger integration-test teardown in integration-tests/debugger/utils.js by waiting for the spawned target app process to fully exit before moving to the next test. The cleanup path now uses a bounded SIGTERM wait, escalates to SIGKILL if needed, and fails explicitly if the process still does not exit.

Motivation

A flaky debugger integration test intermittently observed mismatched trace/span IDs, which is consistent with cross-test leakage when a previous test process is still alive long enough to flush spans into the next test’s fake agent. Enforcing strict process shutdown isolation addresses that root cause instead of relaxing assertions.

Additional Notes

The flaky failure this aims to fix: https://github.com/DataDog/dd-trace-js/actions/runs/22429024616/job/64943721888

Wait for the debugger target app to exit in `afterEach` before
stopping the fake agent and starting the next test.

Use a bounded SIGTERM wait with a SIGKILL fallback, and fail
explicitly if the child still does not exit, to prevent cross-test
span leakage.
@watson watson requested a review from a team as a code owner March 4, 2026 07:32
@watson watson self-assigned this Mar 4, 2026
Copy link
Copy Markdown
Collaborator Author

watson commented Mar 4, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 4, 2026

Overall package size

Self size: 4.89 MB
Deduped: 5.74 MB
No deduping: 5.74 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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.07%. Comparing base (0a08693) to head (e59ba97).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7660      +/-   ##
==========================================
- Coverage   80.29%   80.07%   -0.22%     
==========================================
  Files         738      737       -1     
  Lines       31897    31877      -20     
==========================================
- Hits        25611    25526      -85     
- Misses       6286     6351      +65     
Flag Coverage Δ
aiguard-macos 38.93% <ø> (-0.10%) ⬇️
aiguard-ubuntu 39.04% <ø> (-0.10%) ⬇️
aiguard-windows 38.78% <ø> (-0.10%) ⬇️
apm-capabilities-tracing-macos 48.83% <ø> (ø)
apm-capabilities-tracing-ubuntu 48.87% <ø> (ø)
apm-capabilities-tracing-windows 48.60% <ø> (-0.01%) ⬇️
apm-integrations-child-process 38.51% <ø> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.29% <ø> (-0.24%) ⬇️
apm-integrations-couchbase-eol 37.91% <ø> (+0.04%) ⬆️
apm-integrations-oracledb 37.67% <ø> (-0.17%) ⬇️
appsec-express 55.35% <ø> (-0.08%) ⬇️
appsec-fastify 51.67% <ø> (-0.07%) ⬇️
appsec-graphql 51.86% <ø> (-0.07%) ⬇️
appsec-kafka 44.39% <ø> (-0.03%) ⬇️
appsec-ldapjs 44.03% <ø> (-0.08%) ⬇️
appsec-lodash 43.68% <ø> (-0.08%) ⬇️
appsec-macos 58.35% <ø> (-0.07%) ⬇️
appsec-mongodb-core 48.74% <ø> (-0.19%) ⬇️
appsec-mongoose 49.53% <ø> (-0.08%) ⬇️
appsec-mysql 50.89% <ø> (-0.07%) ⬇️
appsec-node-serialize 43.20% <ø> (-0.08%) ⬇️
appsec-passport 47.65% <ø> (-0.09%) ⬇️
appsec-postgres 50.62% <ø> (-0.10%) ⬇️
appsec-sourcing 42.60% <ø> (-0.08%) ⬇️
appsec-template 43.37% <ø> (-0.08%) ⬇️
appsec-ubuntu 58.43% <ø> (-0.07%) ⬇️
appsec-windows 58.19% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-bluebird 32.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-body-parser 40.48% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-child_process 37.83% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express 34.64% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.44% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-express-session 40.11% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-fs 31.92% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-generic-pool 29.73% <ø> (ø)
instrumentations-instrumentation-http 39.84% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.31% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mongoose 33.45% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-multer 40.23% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-mysql2 38.30% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-passport 44.02% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 43.69% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.23% <ø> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.73% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.24% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-promise-js 32.24% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-q 32.29% <ø> (-0.10%) ⬇️
instrumentations-instrumentation-url 32.21% <ø> (-0.11%) ⬇️
instrumentations-instrumentation-when 32.26% <ø> (-0.10%) ⬇️
llmobs-ai 41.96% <ø> (-0.10%) ⬇️
llmobs-anthropic 40.30% <ø> (-0.09%) ⬇️
llmobs-bedrock 39.25% <ø> (-0.09%) ⬇️
llmobs-google-genai 39.83% <ø> (-0.09%) ⬇️
llmobs-langchain 39.76% <ø> (-0.08%) ⬇️
llmobs-openai 44.14% <ø> (-0.09%) ⬇️
llmobs-vertex-ai 40.09% <ø> (-0.09%) ⬇️
platform-core 31.53% <ø> (ø)
platform-esbuild 34.48% <ø> (ø)
platform-instrumentations-misc 43.94% <ø> (ø)
platform-shimmer 37.63% <ø> (ø)
platform-unit-guardrails 32.95% <ø> (ø)
plugins-azure-event-hubs 25.71% <ø> (ø)
plugins-azure-service-bus 25.07% <ø> (ø)
plugins-bullmq 43.65% <ø> (-0.18%) ⬇️
plugins-cassandra 37.78% <ø> (-0.10%) ⬇️
plugins-cookie 26.77% <ø> (ø)
plugins-cookie-parser 26.56% <ø> (ø)
plugins-crypto 26.79% <ø> (ø)
plugins-dd-trace-api 38.37% <ø> (-0.10%) ⬇️
plugins-express-mongo-sanitize 26.70% <ø> (ø)
plugins-express-session 26.51% <ø> (ø)
plugins-fastify 42.23% <ø> (-0.09%) ⬇️
plugins-fetch 38.33% <ø> (-0.10%) ⬇️
plugins-fs 38.61% <ø> (-0.10%) ⬇️
plugins-generic-pool 25.75% <ø> (ø)
plugins-google-cloud-pubsub 45.37% <ø> (-0.09%) ⬇️
plugins-grpc 40.93% <ø> (-0.09%) ⬇️
plugins-handlebars 26.75% <ø> (ø)
plugins-hapi 40.12% <ø> (-0.10%) ⬇️
plugins-hono 40.38% <ø> (-0.10%) ⬇️
plugins-ioredis 38.42% <ø> (-0.10%) ⬇️
plugins-knex 26.39% <ø> (ø)
plugins-ldapjs 24.24% <ø> (ø)
plugins-light-my-request 26.12% <ø> (ø)
plugins-limitd-client 32.60% <ø> (-0.10%) ⬇️
plugins-lodash 25.84% <ø> (ø)
plugins-mariadb 39.48% <ø> (-0.10%) ⬇️
plugins-memcached 38.17% <ø> (-0.10%) ⬇️
plugins-microgateway-core 39.16% <ø> (-0.10%) ⬇️
plugins-moleculer 40.50% <ø> (-0.10%) ⬇️
plugins-mongodb 39.19% <ø> (-0.10%) ⬇️
plugins-mongodb-core 39.03% <ø> (-0.10%) ⬇️
plugins-mongoose 38.85% <ø> (-0.10%) ⬇️
plugins-multer 26.51% <ø> (ø)
plugins-mysql 39.16% <ø> (-0.10%) ⬇️
plugins-mysql2 39.26% <ø> (-0.10%) ⬇️
plugins-node-serialize 26.81% <ø> (ø)
plugins-opensearch 37.62% <ø> (-0.10%) ⬇️
plugins-passport-http 26.57% <ø> (ø)
plugins-postgres 35.71% <ø> (-0.09%) ⬇️
plugins-process 26.79% <ø> (ø)
plugins-pug 26.77% <ø> (ø)
plugins-redis 38.89% <ø> (-0.10%) ⬇️
plugins-router 42.96% <ø> (-0.10%) ⬇️
plugins-sequelize 25.35% <ø> (ø)
plugins-test-and-upstream-amqp10 38.49% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-amqplib 43.82% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.02% <ø> (-0.09%) ⬇️
plugins-test-and-upstream-avsc ?
plugins-test-and-upstream-bunyan 33.88% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-connect 40.78% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.13% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.36% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 38.93% <ø> (-0.10%) ⬇️
plugins-test-and-upstream-rhea 44.04% <ø> (-0.10%) ⬇️
plugins-undici 39.11% <ø> (-0.09%) ⬇️
plugins-url 26.79% <ø> (ø)
plugins-valkey 38.08% <ø> (-0.10%) ⬇️
plugins-vm 26.79% <ø> (ø)
plugins-winston 34.07% <ø> (-0.10%) ⬇️
plugins-ws 41.87% <ø> (-0.10%) ⬇️
profiling-macos 39.83% <ø> (-0.10%) ⬇️
profiling-ubuntu 39.95% <ø> (-0.10%) ⬇️
profiling-windows 41.16% <ø> (-0.47%) ⬇️
serverless-azure-functions-client 25.43% <ø> (ø)
serverless-azure-functions-eventhubs 25.43% <ø> (ø)
serverless-azure-functions-servicebus 25.43% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 4, 2026

Benchmarks

Benchmark execution time: 2026-03-04 08:01:47

Comparing candidate commit e59ba97 in PR branch watson/flaky-fix2 with baseline commit 0a08693 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 232 metrics, 28 unstable metrics.

Move robust child-process teardown into `integration-tests/helpers`
as `stopProc` and use it in debugger test utils.

This centralizes SIGTERM/SIGKILL shutdown handling and helps
prevent cross-test leakage from lingering processes.
@tlhunter tlhunter merged commit 2c69381 into master Mar 4, 2026
788 checks passed
@tlhunter tlhunter deleted the watson/flaky-fix2 branch March 4, 2026 18:37
dd-octo-sts bot pushed a commit that referenced this pull request Mar 5, 2026
* test(debugger): enforce teardown process isolation

Wait for the debugger target app to exit in `afterEach` before
stopping the fake agent and starting the next test.

Use a bounded SIGTERM wait with a SIGKILL fallback, and fail
explicitly if the child still does not exit, to prevent cross-test
span leakage.

* test(integration): share process stop helper

Move robust child-process teardown into `integration-tests/helpers`
as `stopProc` and use it in debugger test utils.

This centralizes SIGTERM/SIGKILL shutdown handling and helps
prevent cross-test leakage from lingering processes.
@dd-octo-sts dd-octo-sts bot mentioned this pull request Mar 5, 2026
juan-fernandez pushed a commit that referenced this pull request Mar 5, 2026
* test(debugger): enforce teardown process isolation

Wait for the debugger target app to exit in `afterEach` before
stopping the fake agent and starting the next test.

Use a bounded SIGTERM wait with a SIGKILL fallback, and fail
explicitly if the child still does not exit, to prevent cross-test
span leakage.

* test(integration): share process stop helper

Move robust child-process teardown into `integration-tests/helpers`
as `stopProc` and use it in debugger test utils.

This centralizes SIGTERM/SIGKILL shutdown handling and helps
prevent cross-test leakage from lingering processes.
crysmags pushed a commit that referenced this pull request Mar 6, 2026
* test(debugger): enforce teardown process isolation

Wait for the debugger target app to exit in `afterEach` before
stopping the fake agent and starting the next test.

Use a bounded SIGTERM wait with a SIGKILL fallback, and fail
explicitly if the child still does not exit, to prevent cross-test
span leakage.

* test(integration): share process stop helper

Move robust child-process teardown into `integration-tests/helpers`
as `stopProc` and use it in debugger test utils.

This centralizes SIGTERM/SIGKILL shutdown handling and helps
prevent cross-test leakage from lingering processes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants