Repository navigation
fix(esm): register synchronous hooks without require(esm) - #11296
Conversation
Overall package sizeSelf size: 9.48 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.5.3 | 131.25 kB | 531.86 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11296 +/- ##
==========================================
+ Coverage 99.13% 99.14% +0.01%
==========================================
Files 1118 1125 +7
Lines 184942 186323 +1381
Branches 82 86 +4
==========================================
+ Hits 183338 184735 +1397
+ Misses 1603 1588 -15
+ Partials 1 0 -1
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:
|
|
BenchmarksBenchmark execution time: 2026-11-18 18:29:58 Comparing candidate commit 0c5d375 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2446 metrics, 11 unstable metrics.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
What does this PR do?
dd-trace/register.mjsand hasinitialize.mjsawait it, so the synchronous loader can be installed without requiring an ES module from CommonJS.module.register()is available.require(esm), missingmodule.register(), async fallback, and both registration orders.Motivation
AWS Lambda disables
require(esm). The CommonJS registration path therefore falls back tomodule.register(), which Node removed in nodejs/node#67090. Without the fallback, ESM modules load without instrumentation. Using nativeimport()for registration lets the synchronous hooks work without changing the contract ofregister.js.Additional Notes
module.register()is absent, the HTTP instrumentation fixture printedfalseon the unchanged base andtruewith this change, both with--no-experimental-require-module.datadog-lambda-js: its programmatic bootstrap still checks formodule.register()and requiresregister.js. It needs to awaitregister.mjsbefore loading the customer handler and retain compatibility with older tracer releases. No deployed Lambda test was run.Alternative solution to #11277