Skip to content

fix(guardrails): forward abort telemetry synchronously to avoid a hung exit#9268

Merged
rochdev merged 4 commits into
masterfrom
BridgeAR/2026-07-08-ssi-node24-exit-hang
Jul 9, 2026
Merged

fix(guardrails): forward abort telemetry synchronously to avoid a hung exit#9268
rochdev merged 4 commits into
masterfrom
BridgeAR/2026-07-08-ssi-node24-exit-hang

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Single-step install (SSI) injects the tracer via NODE_OPTIONS. On the abort path — an incompatible runtime, where the tracer does not initialize — the guardrails fire abort telemetry by spawning the forwarder with child_process.spawn, then the injected app returns and typically calls process.exit(). On Node 24.0.0/24.1.x a child that is still tearing down its stdio pipes deadlocks process.exit() (fixed upstream in 24.2), so the forwarder keeps the short-lived process alive until it is killed externally.

Because injection is automatic, this hangs a customer's short-lived processes whenever they run SSI on an unsupported Node 24.0.0/24.1 runtime — reproduced without any test harness (~70% of runs in a faithful sandbox; disabling the forwarder drops it to 0).

Forward the abort telemetry with spawnSync so the child is fully reaped before we return and nothing outlives the call to race the exit. The synchronous path runs only on the non-forced bailout, before any instrumentation is active, so the forwarder is never traced; the async spawn stays for the post-init complete point.

Why

spawnSync exists since Node 0.11.12 and the guardrails still target >=0.8, which predates the exit bug, so the async spawn remains the fallback there. The functions are captured at module load, before the tracer wraps child_process, so a forced init that runs afterwards cannot route the forwarder through the tracer's own instrumentation.

This addresses the dominant, product-side cause. A small residual hang remains on Node 24.0.0/24.1 that is the runtime's own process.exit() teardown bug (unreachable from our code, fixed in Node 24.2); the CI guardrail flake it still produces is handled separately.

Refs: nodejs/node#63085

…g exit

Single-step install injects the tracer via NODE_OPTIONS. When it bails out on an
incompatible runtime it fires abort telemetry by spawning the forwarder with
child_process.spawn, then the injected app returns and typically calls
process.exit(). On Node 24.0.0/24.1.x a child still tearing down its stdio pipes
deadlocks process.exit() (fixed upstream in 24.2), so the forwarder keeps the
short-lived process alive until it is killed externally. Because injection is
automatic, an unsupported-runtime customer with short-lived processes gets hangs.

Forward the abort telemetry with spawnSync so the child is fully reaped before we
return and nothing outlives the call to race the exit. The synchronous path runs
only on the non-forced bailout, before any instrumentation is active, so the
forwarder is never traced; the async spawn stays for the post-init `complete`
point. spawnSync exists since Node 0.11.12 and the guardrails still target >=0.8,
which predates the exit bug, so the async path remains the fallback there.

Refs: nodejs/node#63085
@dd-octo-sts

dd-octo-sts Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.69 MB
Deduped: 7.35 MB
No deduping: 7.35 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 437.94 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

@BridgeAR
BridgeAR marked this pull request as ready for review July 8, 2026 19:59
@BridgeAR
BridgeAR requested a review from a team as a code owner July 8, 2026 19:59
initBailout = true
var runtimeInfo = 'Incompatible runtime Node.js ' + version + ', supported runtimes: Node.js ' + supportedRange
// When not forced, the process bails out here and may call process.exit() right away;
// forward synchronously so the telemetry child can't outlive us and wedge the exit.

@rochdev rochdev Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't this be handled properly at the source instead of worked around here?

@BridgeAR BridgeAR Jul 8, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The source being Node.js? This issue is fixed in newer Node.js versions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, the comment wasn't clear that the underlying issue is outside the library, but I see it in another comment 👍

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6717dfb843

ℹ️ 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".

Comment on lines +93 to +95
var result = spawnSync(telemetryForwarderPath, ['library_entrypoint'], {
input: payload,
stdio: ['pipe', 'ignore', 'ignore']

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Add a timeout to the synchronous forwarder

On the unsupported-runtime SSI path, this waits forever for whatever executable DD_TELEMETRY_FORWARDER_PATH names; the only validation above is existsSync, so an existing forwarder or wrapper that wedges or blocks before exiting now hangs the user's process before guardrails return and before the app can reach its own process.exit(). Since this telemetry is best-effort and this change is specifically avoiding hangs, please bound the synchronous send with a short timeout/kill handling or fall back so a bad forwarder cannot become a new hard hang.

Useful? React with 👍 / 👎.

@pr-commenter

pr-commenter Bot commented Jul 8, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-09 17:47:05

Comparing candidate commit 171a96b in PR branch BridgeAR/2026-07-08-ssi-node24-exit-hang with baseline commit f7620c3 in branch master.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

Unstable benchmarks

These benchmarks have a confidence interval too wide to call a change; treat them as noise rather than signal.

scenario:appsec-appsec-enabled-24

  • unstable execution_time [-207.797ms; +212.167ms] or [-7.832%; +7.996%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-237.567ms; +233.322ms] or [-9.300%; +9.134%]

scenario:appsec-appsec-enabled-with-attacks-24

  • unstable execution_time [-162.456ms; +159.054ms] or [-5.276%; +5.166%]

scenario:appsec-appsec-enabled-with-attacks-26

  • unstable execution_time [-185.856ms; +177.547ms] or [-6.414%; +6.127%]

scenario:appsec-control-20

  • unstable execution_time [-128.642ms; +134.128ms] or [-7.776%; +8.107%]

scenario:appsec-control-24

  • unstable execution_time [-112399.961µs; +110607.361µs] or [-9.084%; +8.939%]

scenario:appsec-control-26

  • unstable execution_time [-123468.917µs; +122886.550µs] or [-9.982%; +9.935%]

scenario:appsec-iast-no-vulnerability-iast-enabled-default-config-20

  • unstable execution_time [-17520.532µs; +18817.066µs] or [-6.716%; +7.213%]

scenario:appsec-iast-with-vulnerability-control-20

  • unstable execution_time [-27876.251µs; +29852.317µs] or [-5.065%; +5.424%]

scenario:appsec-iast-with-vulnerability-iast-enabled-always-active-20

  • unstable execution_time [-28.879ms; +31.609ms] or [-5.164%; +5.652%]

scenario:debugger-line-probe-with-snapshot-default-24

  • unstable cpu_user_time [-2722.957ms; +2611.996ms] or [-30.070%; +28.844%]
  • unstable execution_time [-2835.988ms; +2744.721ms] or [-29.027%; +28.093%]
  • unstable instructions [-23216.6M instructions; +22047.4M instructions] or [-31.263%; +29.688%]
  • unstable max_rss_usage [-10991.122KB; +11267.122KB] or [-6.890%; +7.063%]
  • unstable throughput [-710.226op/s; +759.779op/s] or [-20.707%; +22.151%]

scenario:debugger-line-probe-with-snapshot-minimal-24

  • unstable cpu_user_time [-2734.721ms; +2583.833ms] or [-30.261%; +28.591%]
  • unstable execution_time [-2742.694ms; +2596.022ms] or [-28.124%; +26.620%]
  • unstable instructions [-23318.5M instructions; +22097.2M instructions] or [-31.430%; +29.784%]
  • unstable max_rss_usage [-11527.075KB; +11166.275KB] or [-7.233%; +7.007%]
  • unstable throughput [-681.786op/s; +740.816op/s] or [-19.884%; +21.606%]

scenario:debugger-line-probe-without-snapshot-24

  • unstable cpu_user_time [-3.789s; -0.399s] or [-38.772%; -4.078%]
  • unstable execution_time [-3.849s; -0.396s] or [-36.678%; -3.770%]
  • unstable instructions [-32.3G instructions; -3.5G instructions] or [-40.132%; -4.377%]
  • unstable throughput [+107.740op/s; +1073.644op/s] or [+3.323%; +33.116%]

scenario:debugger-line-probe-without-snapshot-26

  • unstable cpu_user_time [-2778.904ms; +4141.721ms] or [-26.474%; +39.457%]
  • unstable execution_time [-2735.432ms; +4158.049ms] or [-24.315%; +36.960%]
  • unstable instructions [-25.0G instructions; +36.9G instructions] or [-28.311%; +41.688%]
  • unstable max_rss_usage [-9.124MB; +12.142MB] or [-5.591%; +7.440%]
  • unstable throughput [-932.680op/s; +569.747op/s] or [-30.901%; +18.877%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-436.308ms; +205.245ms] or [-8.740%; +4.111%]
  • unstable execution_time [-433.152ms; +202.127ms] or [-8.545%; +3.987%]
  • unstable throughput [-69747.558op/s; +146538.159op/s] or [-4.218%; +8.863%]

scenario:plugin-claude-agent-sdk-compact-stream-scan-24

  • unstable cpu_usage_percentage [-6.847%; +3.730%]

scenario:plugin-graphql-long-with-depth-on-max-20

  • unstable cpu_user_time [-738.750ms; +720.880ms] or [-5.753%; +5.614%]
  • unstable execution_time [-747.623ms; +727.703ms] or [-5.696%; +5.544%]
  • unstable throughput [-3.334op/s; +3.465op/s] or [-5.436%; +5.650%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-4059.640KB; +4156.973KB] or [-5.118%; +5.241%]

@datadog-prod-us1-6

datadog-prod-us1-6 Bot commented Jul 8, 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: 96.53% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 171a96b | Docs | Datadog PR Page | Give us feedback!

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.56%. Comparing base (f7620c3) to head (171a96b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #9268    +/-   ##
========================================
  Coverage   96.56%   96.56%            
========================================
  Files         918      918            
  Lines      121521   121560    +39     
  Branches    21522    21004   -518     
========================================
+ Hits       117347   117390    +43     
+ Misses       4174     4170     -4     
Flag Coverage Δ
aiguard 53.55% <16.27%> (-0.09%) ⬇️
aiguard-integration 57.00% <17.50%> (-0.04%) ⬇️
apm-bucket-0 53.78% <23.25%> (-0.09%) ⬇️
apm-bucket-1 58.07% <16.27%> (-0.09%) ⬇️
apm-bucket-2 56.10% <23.25%> (-0.09%) ⬇️
apm-capabilities-tracing 60.31% <16.27%> (-0.03%) ⬇️
apm-integrations-aerospike 52.92% <16.27%> (-0.09%) ⬇️
apm-integrations-confluentinc-kafka-javascript 57.05% <16.27%> (-0.03%) ⬇️
apm-integrations-couchbase 53.27% <23.25%> (-0.08%) ⬇️
apm-integrations-http 57.95% <16.27%> (-0.09%) ⬇️
apm-integrations-kafkajs 57.70% <16.27%> (-0.10%) ⬇️
apm-integrations-next 54.23% <16.27%> (-0.09%) ⬇️
apm-integrations-prisma 54.16% <16.27%> (-0.08%) ⬇️
apm-integrations-tedious 53.03% <16.27%> (-0.09%) ⬇️
appsec 69.01% <16.27%> (-0.08%) ⬇️
appsec-express_fastify_graphql 65.59% <16.27%> (-0.09%) ⬇️
appsec-integration 45.58% <17.50%> (-0.02%) ⬇️
appsec-kafka_ldapjs_lodash 59.08% <16.27%> (-0.08%) ⬇️
appsec-mongodb-core_mongoose_mysql 62.24% <16.27%> (-0.08%) ⬇️
appsec-next 52.84% <16.27%> (-0.08%) ⬇️
appsec-node-serialize_passport_postgres 61.87% <16.27%> (-0.08%) ⬇️
appsec-sourcing_stripe_template 60.22% <16.27%> (-0.06%) ⬇️
debugger 65.70% <23.25%> (-0.07%) ⬇️
instrumentations-bucket-0 48.74% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-1 54.94% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-10 56.61% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-11 48.73% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-12 48.83% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-13 48.66% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-2 49.72% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-3 53.82% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-4 49.15% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-5 53.00% <16.27%> (-0.08%) ⬇️
instrumentations-bucket-6 55.59% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-7 53.59% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-8 54.62% <16.27%> (-0.09%) ⬇️
instrumentations-bucket-9 56.09% <16.27%> (-0.08%) ⬇️
instrumentations-instrumentation-couchbase 48.17% <23.25%> (-0.09%) ⬇️
instrumentations-integration-esbuild 33.95% <17.50%> (-0.02%) ⬇️
llmobs-ai_anthropic_bedrock 57.72% <16.27%> (-0.08%) ⬇️
llmobs-bucket-1 56.98% <16.27%> (-0.07%) ⬇️
llmobs-openai 57.55% <16.27%> (-0.08%) ⬇️
llmobs-sdk 59.94% <16.27%> (-0.10%) ⬇️
llmobs-vertex-ai 54.20% <16.27%> (-0.09%) ⬇️
master-coverage 96.56% <100.00%> (?)
openfeature 54.61% <17.50%> (-0.04%) ⬇️
openfeature-unit 49.82% <16.27%> (-0.09%) ⬇️
platform-core_esbuild_instrumentations-misc 38.43% <16.27%> (-0.04%) ⬇️
platform-integration 62.23% <83.72%> (+0.01%) ⬆️
platform-shimmer_unit-guardrails_webpack 37.28% <93.02%> (?)
platform-shimmer_webpack ?
plugins-bucket-0 53.17% <16.27%> (-0.08%) ⬇️
plugins-bucket-1 55.07% <16.27%> (-0.05%) ⬇️
plugins-bucket-11 55.56% <16.27%> (-0.08%) ⬇️
plugins-bucket-18 57.06% <16.27%> (-0.09%) ⬇️
plugins-bucket-19 55.35% <16.27%> (-0.12%) ⬇️
plugins-bucket-20 57.43% <16.27%> (-0.09%) ⬇️
plugins-bucket-4 53.84% <16.27%> (-0.09%) ⬇️
plugins-bullmq_cassandra_cookie 57.39% <16.27%> (-0.09%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 52.31% <16.27%> (-0.09%) ⬇️
plugins-fetch_fs_generic-pool 54.45% <16.27%> (-0.09%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 59.86% <16.27%> (-0.09%) ⬇️
plugins-hapi_hono_ioredis 55.85% <16.27%> (-0.09%) ⬇️
plugins-jest_knex_langgraph 51.65% <16.27%> (-0.09%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 53.40% <16.27%> (-0.11%) ⬇️
plugins-lodash_mariadb_memcached 54.20% <16.27%> (-0.09%) ⬇️
plugins-moleculer_mongodb_mongodb-core 57.28% <16.27%> (-0.09%) ⬇️
plugins-mongoose_multer_mysql 54.70% <16.27%> (-0.09%) ⬇️
plugins-mysql2_nats_node-serialize 56.20% <16.27%> (-0.09%) ⬇️
plugins-opensearch_passport-http_pino 55.04% <16.27%> (-0.09%) ⬇️
plugins-postgres_process_pug 54.28% <16.27%> (-0.09%) ⬇️
plugins-redis_router_sequelize 57.02% <16.27%> (-0.09%) ⬇️
plugins-test-and-upstream-rhea_undici_url 57.02% <16.27%> (-0.09%) ⬇️
plugins-valkey_vm_winston 53.92% <16.27%> (-0.09%) ⬇️
plugins-ws 54.79% <16.27%> (-0.09%) ⬇️
profiling 58.19% <16.27%> (-0.09%) ⬇️
serverless-aws-sdk-aws-sdk 50.66% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-bedrockruntime 50.67% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-client 51.96% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-dynamodb 51.74% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-eventbridge 46.23% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-kinesis 54.70% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-lambda 52.78% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-s3 51.52% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-serverless-peer-service 54.72% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-sns 55.59% <16.27%> (+0.03%) ⬆️
serverless-aws-sdk-sqs 55.90% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-stepfunctions 51.24% <16.27%> (-0.08%) ⬇️
serverless-aws-sdk-util 48.46% <16.27%> (-0.09%) ⬇️
serverless-bucket-0 55.21% <16.27%> (-0.04%) ⬇️
serverless-bucket-1 55.99% <16.27%> (-0.09%) ⬇️
test-optimization-cucumber 72.95% <17.50%> (-0.06%) ⬇️
test-optimization-cypress 66.39% <17.50%> (+0.04%) ⬆️
test-optimization-jest 73.93% <16.27%> (-0.04%) ⬇️
test-optimization-mocha 74.36% <16.27%> (+0.07%) ⬆️
test-optimization-playwright-playwright-atr 61.56% <17.50%> (-0.05%) ⬇️
test-optimization-playwright-playwright-efd 61.81% <17.50%> (+0.02%) ⬆️
test-optimization-playwright-playwright-final-status 61.70% <17.50%> (-0.05%) ⬇️
test-optimization-playwright-playwright-impacted-tests 61.43% <17.50%> (+0.12%) ⬆️
test-optimization-playwright-playwright-reporting 61.33% <17.50%> (-0.05%) ⬇️
test-optimization-playwright-playwright-test-management 62.24% <17.50%> (-0.16%) ⬇️
test-optimization-playwright-playwright-test-span 61.46% <17.50%> (-0.11%) ⬇️
test-optimization-selenium 60.66% <17.50%> (-0.15%) ⬇️
test-optimization-testopt 59.15% <16.27%> (+0.05%) ⬆️
test-optimization-vitest 72.48% <17.50%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

rochdev
rochdev previously approved these changes Jul 8, 2026
…e exit

The synchronous bailout path validates only that DD_TELEMETRY_FORWARDER_PATH
exists, then blocks on spawnSync with no timeout. A forwarder or wrapper that
wedges before exiting would hang the injected process before guardrails return
and before the app can reach its own process.exit() — reintroducing the exact
hard hang this change exists to remove. Bound the send with a 1s timeout and
SIGKILL, and log ETIMEDOUT distinctly; the telemetry is best-effort, so a bad
forwarder degrades to a dropped point instead of a stuck process.
BridgeAR and others added 2 commits July 9, 2026 18:36
The spawnSync bailout path logs two failures that had no coverage: a
non-ETIMEDOUT spawn error (a forwarder that exists but cannot execute, e.g.
EACCES) and a non-zero forwarder exit code. Both are reachable and mirror the
async path's handling, so they get real cases beside the existing ETIMEDOUT
test using the same mocked-spawnSync pattern.
@rochdev
rochdev merged commit 05a9f7c into master Jul 9, 2026
655 checks passed
@rochdev
rochdev deleted the BridgeAR/2026-07-08-ssi-node24-exit-hang branch July 9, 2026 23:41
dd-octo-sts Bot pushed a commit that referenced this pull request Jul 10, 2026
…g exit (#9268)

* fix(guardrails): forward abort telemetry synchronously to avoid a hung exit

Single-step install injects the tracer via NODE_OPTIONS. When it bails out on an
incompatible runtime it fires abort telemetry by spawning the forwarder with
child_process.spawn, then the injected app returns and typically calls
process.exit(). On Node 24.0.0/24.1.x a child still tearing down its stdio pipes
deadlocks process.exit() (fixed upstream in 24.2), so the forwarder keeps the
short-lived process alive until it is killed externally. Because injection is
automatic, an unsupported-runtime customer with short-lived processes gets hangs.

Forward the abort telemetry with spawnSync so the child is fully reaped before we
return and nothing outlives the call to race the exit. The synchronous path runs
only on the non-forced bailout, before any instrumentation is active, so the
forwarder is never traced; the async spawn stays for the post-init `complete`
point. spawnSync exists since Node 0.11.12 and the guardrails still target >=0.8,
which predates the exit bug, so the async path remains the fallback there.

Refs: nodejs/node#63085

* fix(guardrails): bound the synchronous forwarder so it cannot hang the exit

The synchronous bailout path validates only that DD_TELEMETRY_FORWARDER_PATH
exists, then blocks on spawnSync with no timeout. A forwarder or wrapper that
wedges before exiting would hang the injected process before guardrails return
and before the app can reach its own process.exit() — reintroducing the exact
hard hang this change exists to remove. Bound the send with a 1s timeout and
SIGKILL, and log ETIMEDOUT distinctly; the telemetry is best-effort, so a bad
forwarder degrades to a dropped point instead of a stuck process.

* test(guardrails): cover the synchronous forwarder error branches

The spawnSync bailout path logs two failures that had no coverage: a
non-ETIMEDOUT spawn error (a forwarder that exists but cannot execute, e.g.
EACCES) and a non-zero forwarder exit code. Both are reachable and mirror the
async path's handling, so they get real cases beside the existing ETIMEDOUT
test using the same mocked-spawnSync pattern.
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 10, 2026
dd-octo-sts Bot pushed a commit that referenced this pull request Jul 10, 2026
…g exit (#9268)

* fix(guardrails): forward abort telemetry synchronously to avoid a hung exit

Single-step install injects the tracer via NODE_OPTIONS. When it bails out on an
incompatible runtime it fires abort telemetry by spawning the forwarder with
child_process.spawn, then the injected app returns and typically calls
process.exit(). On Node 24.0.0/24.1.x a child still tearing down its stdio pipes
deadlocks process.exit() (fixed upstream in 24.2), so the forwarder keeps the
short-lived process alive until it is killed externally. Because injection is
automatic, an unsupported-runtime customer with short-lived processes gets hangs.

Forward the abort telemetry with spawnSync so the child is fully reaped before we
return and nothing outlives the call to race the exit. The synchronous path runs
only on the non-forced bailout, before any instrumentation is active, so the
forwarder is never traced; the async spawn stays for the post-init `complete`
point. spawnSync exists since Node 0.11.12 and the guardrails still target >=0.8,
which predates the exit bug, so the async path remains the fallback there.

Refs: nodejs/node#63085

* fix(guardrails): bound the synchronous forwarder so it cannot hang the exit

The synchronous bailout path validates only that DD_TELEMETRY_FORWARDER_PATH
exists, then blocks on spawnSync with no timeout. A forwarder or wrapper that
wedges before exiting would hang the injected process before guardrails return
and before the app can reach its own process.exit() — reintroducing the exact
hard hang this change exists to remove. Bound the send with a 1s timeout and
SIGKILL, and log ETIMEDOUT distinctly; the telemetry is best-effort, so a bad
forwarder degrades to a dropped point instead of a stuck process.

* test(guardrails): cover the synchronous forwarder error branches

The spawnSync bailout path logs two failures that had no coverage: a
non-ETIMEDOUT spawn error (a forwarder that exists but cannot execute, e.g.
EACCES) and a non-zero forwarder exit code. Both are reachable and mirror the
async path's handling, so they get real cases beside the existing ETIMEDOUT
test using the same mocked-spawnSync pattern.
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Jul 10, 2026
juan-fernandez pushed a commit that referenced this pull request Jul 10, 2026
…g exit (#9268)

* fix(guardrails): forward abort telemetry synchronously to avoid a hung exit

Single-step install injects the tracer via NODE_OPTIONS. When it bails out on an
incompatible runtime it fires abort telemetry by spawning the forwarder with
child_process.spawn, then the injected app returns and typically calls
process.exit(). On Node 24.0.0/24.1.x a child still tearing down its stdio pipes
deadlocks process.exit() (fixed upstream in 24.2), so the forwarder keeps the
short-lived process alive until it is killed externally. Because injection is
automatic, an unsupported-runtime customer with short-lived processes gets hangs.

Forward the abort telemetry with spawnSync so the child is fully reaped before we
return and nothing outlives the call to race the exit. The synchronous path runs
only on the non-forced bailout, before any instrumentation is active, so the
forwarder is never traced; the async spawn stays for the post-init `complete`
point. spawnSync exists since Node 0.11.12 and the guardrails still target >=0.8,
which predates the exit bug, so the async path remains the fallback there.

Refs: nodejs/node#63085

* fix(guardrails): bound the synchronous forwarder so it cannot hang the exit

The synchronous bailout path validates only that DD_TELEMETRY_FORWARDER_PATH
exists, then blocks on spawnSync with no timeout. A forwarder or wrapper that
wedges before exiting would hang the injected process before guardrails return
and before the app can reach its own process.exit() — reintroducing the exact
hard hang this change exists to remove. Bound the send with a 1s timeout and
SIGKILL, and log ETIMEDOUT distinctly; the telemetry is best-effort, so a bad
forwarder degrades to a dropped point instead of a stuck process.

* test(guardrails): cover the synchronous forwarder error branches

The spawnSync bailout path logs two failures that had no coverage: a
non-ETIMEDOUT spawn error (a forwarder that exists but cannot execute, e.g.
EACCES) and a non-zero forwarder exit code. Both are reachable and mirror the
async path's handling, so they get real cases beside the existing ETIMEDOUT
test using the same mocked-spawnSync pattern.
juan-fernandez pushed a commit that referenced this pull request Jul 10, 2026
…g exit (#9268)

* fix(guardrails): forward abort telemetry synchronously to avoid a hung exit

Single-step install injects the tracer via NODE_OPTIONS. When it bails out on an
incompatible runtime it fires abort telemetry by spawning the forwarder with
child_process.spawn, then the injected app returns and typically calls
process.exit(). On Node 24.0.0/24.1.x a child still tearing down its stdio pipes
deadlocks process.exit() (fixed upstream in 24.2), so the forwarder keeps the
short-lived process alive until it is killed externally. Because injection is
automatic, an unsupported-runtime customer with short-lived processes gets hangs.

Forward the abort telemetry with spawnSync so the child is fully reaped before we
return and nothing outlives the call to race the exit. The synchronous path runs
only on the non-forced bailout, before any instrumentation is active, so the
forwarder is never traced; the async spawn stays for the post-init `complete`
point. spawnSync exists since Node 0.11.12 and the guardrails still target >=0.8,
which predates the exit bug, so the async path remains the fallback there.

Refs: nodejs/node#63085

* fix(guardrails): bound the synchronous forwarder so it cannot hang the exit

The synchronous bailout path validates only that DD_TELEMETRY_FORWARDER_PATH
exists, then blocks on spawnSync with no timeout. A forwarder or wrapper that
wedges before exiting would hang the injected process before guardrails return
and before the app can reach its own process.exit() — reintroducing the exact
hard hang this change exists to remove. Bound the send with a 1s timeout and
SIGKILL, and log ETIMEDOUT distinctly; the telemetry is best-effort, so a bad
forwarder degrades to a dropped point instead of a stuck process.

* test(guardrails): cover the synchronous forwarder error branches

The spawnSync bailout path logs two failures that had no coverage: a
non-ETIMEDOUT spawn error (a forwarder that exists but cannot execute, e.g.
EACCES) and a non-zero forwarder exit code. Both are reachable and mirror the
async path's handling, so they get real cases beside the existing ETIMEDOUT
test using the same mocked-spawnSync pattern.
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.

3 participants