Skip to content

fix(esm): skip loader hook registration when instrumentation bails out#9242

Merged
BridgeAR merged 1 commit into
masterfrom
BridgeAR/2026-07-07-initialize-skip-loader-on-bailout
Jul 8, 2026
Merged

fix(esm): skip loader hook registration when instrumentation bails out#9242
BridgeAR merged 1 commit into
masterfrom
BridgeAR/2026-07-07-initialize-skip-loader-on-bailout

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

--import dd-trace/initialize.mjs on an unsupported runtime, or as a single-step install that defers to a manually-installed copy, still registered the async ESM loader even though the tracer never initialized. With nothing to instrument, that loader can keep a short-lived process from exiting — the hanging --import guardrail children seen on Node 24.

init.js returns the tracer on success and undefined on a bailout, so the registration is now gated on that result. The --import guardrail cases drop the kill timer so a child that fails to exit fails the suite instead of being masked.

`--import dd-trace/initialize.mjs` on an unsupported runtime, or as a single-step
install that defers to a manually-installed copy, still registered the async ESM
loader even though the tracer never initialized. With nothing to instrument, that
loader can keep a short-lived process from exiting — the hanging `--import`
guardrail children seen on Node 24.

`init.js` returns the tracer on success and `undefined` on a bailout, so gate the
registration on that result. The `--import` guardrail cases drop the kill timer so
a child that fails to exit fails the suite instead of being masked.
@dd-octo-sts

dd-octo-sts Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Overall package size

Self size: 6.65 MB
Deduped: 7.31 MB
No deduping: 7.31 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 7, 2026 22:06
@BridgeAR
BridgeAR requested a review from a team as a code owner July 7, 2026 22:06
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Jul 7, 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.50% (+0.00%)

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

@pr-commenter

pr-commenter Bot commented Jul 7, 2026

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2026-07-07 22:15:31

Comparing candidate commit c02a598 in PR branch BridgeAR/2026-07-07-initialize-skip-loader-on-bailout with baseline commit 221c2fb in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 2315 metrics, 43 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 [-213.529ms; +225.152ms] or [-7.988%; +8.423%]

scenario:appsec-appsec-enabled-26

  • unstable execution_time [-239.152ms; +245.438ms] or [-9.361%; +9.607%]

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

  • unstable execution_time [-154.304ms; +168.669ms] or [-4.976%; +5.439%]

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

  • unstable execution_time [-187.083ms; +191.970ms] or [-6.341%; +6.507%]

scenario:appsec-control-20

  • unstable execution_time [-112.521ms; +125.304ms] or [-6.874%; +7.655%]

scenario:appsec-control-24

  • unstable execution_time [-120.766ms; +118.419ms] or [-9.726%; +9.537%]

scenario:appsec-control-26

  • unstable execution_time [-123121.547µs; +123438.714µs] or [-9.985%; +10.011%]

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

  • unstable execution_time [-16.815ms; +12.237ms] or [-6.459%; +4.700%]

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

  • unstable execution_time [-14000.845µs; +13022.912µs] or [-5.508%; +5.123%]

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

  • unstable execution_time [-30.572ms; +33.690ms] or [-5.454%; +6.011%]

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

  • unstable execution_time [-33.574ms; +37.232ms] or [-6.075%; +6.737%]

scenario:child_process-shell-string-24

  • unstable execution_time [-14.316ms; +20.245ms] or [-4.355%; +6.159%]

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

  • unstable cpu_user_time [-3795.637ms; +4087.778ms] or [-33.419%; +35.991%]
  • unstable execution_time [-3771.447ms; +4095.453ms] or [-31.148%; +33.824%]
  • unstable instructions [-33.9G instructions; +36.7G instructions] or [-35.344%; +38.271%]
  • unstable max_rss_usage [-12239.353KB; +12637.753KB] or [-7.410%; +7.651%]
  • unstable throughput [-833.208op/s; +785.543op/s] or [-29.450%; +27.765%]

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

  • unstable cpu_user_time [-1346.239ms; +598.030ms] or [-15.661%; +6.957%]
  • unstable execution_time [-1379.230ms; +666.438ms] or [-14.790%; +7.146%]
  • unstable instructions [-11.4G instructions; +5.0G instructions] or [-16.178%; +7.135%]
  • unstable throughput [-222.351op/s; +373.887op/s] or [-6.343%; +10.666%]

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

  • unstable cpu_user_time [-1793.434ms; +573.695ms] or [-19.168%; +6.132%]
  • unstable execution_time [-1822.073ms; +563.693ms] or [-18.099%; +5.599%]
  • unstable instructions [-16.2G instructions; +5.2G instructions] or [-20.774%; +6.635%]
  • unstable throughput [-122.295op/s; +403.200op/s] or [-3.753%; +12.374%]

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

  • unstable cpu_user_time [-2.551s; +0.323s] or [-29.056%; +3.681%]
  • unstable execution_time [-2.561s; +0.339s] or [-26.977%; +3.568%]
  • unstable instructions [-21.5G instructions; +2.8G instructions] or [-29.863%; +3.942%]
  • unstable throughput [-93.886op/s; +708.341op/s] or [-2.666%; +20.113%]

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

  • unstable cpu_user_time [-2920.308ms; +4121.986ms] or [-27.620%; +38.986%]
  • unstable execution_time [-3014.548ms; +4250.784ms] or [-26.674%; +37.613%]
  • unstable instructions [-25.5G instructions; +36.4G instructions] or [-28.676%; +40.903%]
  • unstable max_rss_usage [-10.088MB; +12.409MB] or [-6.198%; +7.624%]
  • unstable throughput [-917.253op/s; +663.768op/s] or [-30.578%; +22.128%]

scenario:dogstatsd-with-tags-20

  • unstable cpu_user_time [-312.011ms; +393.916ms] or [-6.241%; +7.879%]
  • unstable execution_time [-312.608ms; +394.625ms] or [-6.161%; +7.777%]
  • unstable throughput [-137303.096op/s; +106645.009op/s] or [-8.289%; +6.438%]

scenario:plugin-graphql-long-with-depth-off-20

  • unstable max_rss_usage [-5.921MB; +8.227MB] or [-4.676%; +6.496%]

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

  • unstable cpu_user_time [-728132.638µs; +729818.338µs] or [-5.697%; +5.711%]
  • unstable execution_time [-733.558ms; +740.062ms] or [-5.613%; +5.663%]
  • unstable throughput [-3.425op/s; +3.397op/s] or [-5.559%; +5.514%]

scenario:plugin-pg-service-26

  • unstable execution_time [-63.901ms; +27.968ms] or [-7.012%; +3.069%]

scenario:test-optimization-large-suite-20

  • unstable max_rss_usage [-5160.165KB; +3899.832KB] or [-6.436%; +4.864%]

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.54%. Comparing base (221c2fb) to head (c02a598).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9242   +/-   ##
=======================================
  Coverage   96.54%   96.54%           
=======================================
  Files         915      915           
  Lines      121018   121020    +2     
  Branches    20840    20925   +85     
=======================================
+ Hits       116835   116839    +4     
+ Misses       4183     4181    -2     
Flag Coverage Δ
aiguard 53.64% <ø> (+0.02%) ⬆️
aiguard-integration 57.01% <ø> (ø)
apm-bucket-0 53.80% <ø> (-0.05%) ⬇️
apm-bucket-1 58.11% <ø> (-0.05%) ⬇️
apm-bucket-2 56.12% <ø> (-0.05%) ⬇️
apm-capabilities-tracing 60.30% <ø> (ø)
apm-integrations-aerospike 52.95% <ø> (-0.05%) ⬇️
apm-integrations-confluentinc-kafka-javascript 57.01% <ø> (-0.12%) ⬇️
apm-integrations-couchbase 53.27% <ø> (-0.05%) ⬇️
apm-integrations-http 57.99% <ø> (-0.05%) ⬇️
apm-integrations-kafkajs 57.75% <ø> (-0.03%) ⬇️
apm-integrations-next 54.25% <ø> (-0.05%) ⬇️
apm-integrations-prisma 54.19% <ø> (-0.05%) ⬇️
apm-integrations-tedious 53.05% <ø> (-0.05%) ⬇️
appsec 69.05% <ø> (-0.09%) ⬇️
appsec-express_fastify_graphql 65.70% <ø> (-0.05%) ⬇️
appsec-integration 45.51% <ø> (ø)
appsec-kafka_ldapjs_lodash 59.13% <ø> (-0.04%) ⬇️
appsec-mongodb-core_mongoose_mysql 62.29% <ø> (-0.04%) ⬇️
appsec-next 52.86% <ø> (-0.04%) ⬇️
appsec-node-serialize_passport_postgres 61.93% <ø> (-0.04%) ⬇️
appsec-sourcing_stripe_template 60.27% <ø> (-0.04%) ⬇️
debugger 65.72% <100.00%> (+<0.01%) ⬆️
instrumentations-bucket-0 48.75% <ø> (-0.05%) ⬇️
instrumentations-bucket-1 54.98% <ø> (?)
instrumentations-bucket-10 56.65% <ø> (-0.05%) ⬇️
instrumentations-bucket-11 48.74% <ø> (-0.05%) ⬇️
instrumentations-bucket-12 48.85% <ø> (-0.05%) ⬇️
instrumentations-bucket-13 48.68% <ø> (-0.05%) ⬇️
instrumentations-bucket-2 49.74% <ø> (-0.05%) ⬇️
instrumentations-bucket-3 53.84% <ø> (-0.05%) ⬇️
instrumentations-bucket-4 49.17% <ø> (-0.05%) ⬇️
instrumentations-bucket-5 53.02% <ø> (-0.05%) ⬇️
instrumentations-bucket-6 55.63% <ø> (-0.05%) ⬇️
instrumentations-bucket-7 53.61% <ø> (-0.05%) ⬇️
instrumentations-bucket-8 54.65% <ø> (-0.05%) ⬇️
instrumentations-bucket-9 56.11% <ø> (-0.04%) ⬇️
instrumentations-instrumentation-couchbase 48.17% <ø> (-0.05%) ⬇️
instrumentations-integration-esbuild 33.91% <ø> (ø)
llmobs-ai_anthropic_bedrock 57.76% <100.00%> (-0.04%) ⬇️
llmobs-bucket-1 56.82% <100.00%> (-0.03%) ⬇️
llmobs-openai 57.59% <100.00%> (-0.04%) ⬇️
llmobs-sdk 59.99% <ø> (-0.05%) ⬇️
llmobs-vertex-ai 54.22% <ø> (-0.05%) ⬇️
master-coverage 96.54% <100.00%> (?)
openfeature 54.62% <ø> (+<0.01%) ⬆️
openfeature-unit 49.82% <ø> (-0.05%) ⬇️
platform-core_esbuild_instrumentations-misc 38.38% <ø> (-0.03%) ⬇️
platform-integration 62.19% <100.00%> (+<0.01%) ⬆️
platform-shimmer_unit-guardrails_webpack 37.19% <ø> (-0.03%) ⬇️
plugins-bucket-0 53.19% <100.00%> (-0.04%) ⬇️
plugins-bucket-1 55.08% <ø> (ø)
plugins-bucket-11 56.74% <ø> (-0.05%) ⬇️
plugins-bucket-17 56.76% <ø> (-0.05%) ⬇️
plugins-bucket-18 57.61% <ø> (-0.05%) ⬇️
plugins-bucket-19 57.14% <ø> (-0.05%) ⬇️
plugins-bucket-20 59.39% <ø> (-0.05%) ⬇️
plugins-bucket-4 53.86% <ø> (-0.05%) ⬇️
plugins-bullmq_cassandra_cookie 57.41% <ø> (-0.05%) ⬇️
plugins-cookie-parser_crypto_dd-trace-api 52.33% <ø> (-0.05%) ⬇️
plugins-fetch_fs_generic-pool 54.47% <ø> (-0.05%) ⬇️
plugins-google-cloud-pubsub_grpc_handlebars 59.89% <ø> (-0.05%) ⬇️
plugins-hapi_hono_ioredis 55.88% <ø> (-0.05%) ⬇️
plugins-jest_knex_langgraph 51.67% <ø> (-0.05%) ⬇️
plugins-ldapjs_light-my-request_limitd-client 53.45% <ø> (-0.05%) ⬇️
plugins-lodash_mariadb_memcached 54.22% <ø> (-0.05%) ⬇️
plugins-mongodb_mongodb-core_mongoose 55.47% <ø> (-0.05%) ⬇️
plugins-multer_mysql_mysql2 54.38% <ø> (-0.05%) ⬇️
plugins-nats_node-serialize_opensearch 56.08% <ø> (-0.05%) ⬇️
plugins-passport-http_pino_postgres 54.76% <ø> (-0.05%) ⬇️
plugins-process_pug_redis 53.88% <ø> (-0.05%) ⬇️
plugins-undici_url_valkey 54.31% <ø> (-0.13%) ⬇️
plugins-vm_winston_ws 55.28% <ø> (-0.05%) ⬇️
profiling 58.22% <ø> (-0.05%) ⬇️
serverless-aws-sdk-aws-sdk 50.67% <ø> (-0.04%) ⬇️
serverless-aws-sdk-bedrockruntime 50.68% <ø> (-0.05%) ⬇️
serverless-aws-sdk-client 51.96% <ø> (-0.05%) ⬇️
serverless-aws-sdk-dynamodb 51.79% <ø> (-0.01%) ⬇️
serverless-aws-sdk-eventbridge 46.22% <ø> (-0.05%) ⬇️
serverless-aws-sdk-kinesis 54.71% <ø> (-0.05%) ⬇️
serverless-aws-sdk-lambda 52.79% <ø> (-0.05%) ⬇️
serverless-aws-sdk-s3 51.53% <ø> (-0.05%) ⬇️
serverless-aws-sdk-serverless-peer-service 54.77% <ø> (-0.01%) ⬇️
serverless-aws-sdk-sns 55.49% <ø> (-0.05%) ⬇️
serverless-aws-sdk-sqs 55.92% <ø> (-0.10%) ⬇️
serverless-aws-sdk-stepfunctions 51.25% <ø> (-0.05%) ⬇️
serverless-aws-sdk-util 48.46% <ø> (-0.05%) ⬇️
serverless-bucket-0 55.24% <ø> (ø)
serverless-bucket-1 56.02% <ø> (-0.05%) ⬇️
test-optimization-cucumber 72.94% <ø> (-0.04%) ⬇️
test-optimization-cypress 66.46% <ø> (+0.07%) ⬆️
test-optimization-jest 73.91% <ø> (-0.05%) ⬇️
test-optimization-mocha 74.32% <ø> (+0.04%) ⬆️
test-optimization-playwright-playwright-atr 61.59% <ø> (-0.01%) ⬇️
test-optimization-playwright-playwright-efd 61.78% <ø> (ø)
test-optimization-playwright-playwright-final-status 61.73% <ø> (-0.01%) ⬇️
test-optimization-playwright-playwright-impacted-tests 61.46% <ø> (+0.16%) ⬆️
test-optimization-playwright-playwright-reporting 61.60% <ø> (+0.05%) ⬆️
test-optimization-playwright-playwright-test-management 62.27% <ø> (-0.12%) ⬇️
test-optimization-playwright-playwright-test-span 61.50% <ø> (-0.06%) ⬇️
test-optimization-selenium 60.69% <ø> (-0.17%) ⬇️
test-optimization-testopt 59.15% <ø> (+0.08%) ⬆️
test-optimization-vitest 72.76% <ø> (+0.03%) ⬆️

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.

@BridgeAR
BridgeAR merged commit 6ffe627 into master Jul 8, 2026
655 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-07-07-initialize-skip-loader-on-bailout branch July 8, 2026 11:43
This was referenced Jul 9, 2026
juan-fernandez pushed a commit that referenced this pull request Jul 10, 2026
#9242)

`--import dd-trace/initialize.mjs` on an unsupported runtime, or as a single-step
install that defers to a manually-installed copy, still registered the async ESM
loader even though the tracer never initialized. With nothing to instrument, that
loader can keep a short-lived process from exiting — the hanging `--import`
guardrail children seen on Node 24.

`init.js` returns the tracer on success and `undefined` on a bailout, so gate the
registration on that result. The `--import` guardrail cases drop the kill timer so
a child that fails to exit fails the suite instead of being masked.
juan-fernandez pushed a commit that referenced this pull request Jul 10, 2026
#9242)

`--import dd-trace/initialize.mjs` on an unsupported runtime, or as a single-step
install that defers to a manually-installed copy, still registered the async ESM
loader even though the tracer never initialized. With nothing to instrument, that
loader can keep a short-lived process from exiting — the hanging `--import`
guardrail children seen on Node 24.

`init.js` returns the tracer on success and `undefined` on a bailout, so gate the
registration on that result. The `--import` guardrail cases drop the kill timer so
a child that fails to exit fails the suite instead of being masked.
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