fix(esm): skip loader hook registration when instrumentation bails out#9242
Conversation
`--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.
Overall package sizeSelf size: 6.65 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 |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: c02a598 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-07 22:15:31 Comparing candidate commit c02a598 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2315 metrics, 43 unstable metrics.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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 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:
|
#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.
#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.
Summary
--import dd-trace/initialize.mjson 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--importguardrail children seen on Node 24.init.jsreturns the tracer on success andundefinedon a bailout, so the registration is now gated on that result. The--importguardrail cases drop the kill timer so a child that fails to exit fails the suite instead of being masked.