Immutable solution version
@highlight-run/node 3.4.x: Dynamic require of async_hooks is not supported
Complete solution
What this covers: Importing `@highlight-run/node` (3.4.0/3.4.2) and calling `H.init({ projectID })` throws `Error: Dynamic require of "async_hooks" is not supported` at runtime. The fix that worked: Highlight's maintainer traced it to their ESM bundling being incompatible with the OpenTelemetry SDKs, and shipped a fix in @highlight-run/node 3.5.0 and @highlight-run/next 7.0.1.
@highlight-run/node 3.4.x: Dynamic require of async_hooks is not supported
Whats going on
Importing @highlight-run/node (3.4.0/3.4.2) and calling H.init({ projectID }) throws Error: Dynamic require of "async_hooks" is not supported at runtime. The stack trace shows the bundled dist/index.mjs trying to __require2 Node builtins through @opentelemetry/context-async-hooks and @opentelemetry/sdk-trace-node. It happens locally as well as in deployments, not just in the Edge runtime.
What actually fixes it
Highlight's maintainer traced it to their ESM bundling being incompatible with the OpenTelemetry SDKs, and shipped a fix in @highlight-run/node 3.5.0 and @highlight-run/next 7.0.1. If you are stuck on 3.4.x with this exact error, upgrading to 3.5.0 or later is the fix; avoid running H.init via the instrumentation hook, since the team recommends API endpoint wrappers over instrumentation for reliability.
Original thread
https://vectle.com/threads/thr_GFdO7H8nNQEFwQxvHPW4eA
Evidence
In the thread https://vectle.com/threads/thrGFdO7H8nNQEFwQxvHPW4eA, the question was: Importing @highlight-run/node (3.4.0/3.4.2) and calling H.init({ projectID }) throws `Error: Dynamic require of "asynchooks" is not supported at runtime. The stack trace shows the bundled dist/index.mjs trying to __require2 Node builtins through @opentelemetry/context-async-hooks and @opentelemetry/sdk-trace-node. It happens locally as well as in deployments, not just in the Edge runtime. The verified resolution was: Highlight's maintainer traced it to their ESM bundling being incompatible with the OpenTelemetry SDKs, and shipped a fix in @highlight-run/node 3.5.0 and @highlight-run/next 7.0.1. If you are stuck on 3.4.x with this exact error, upgrading to 3.5.0 or later is the fix; avoid running H.init` via the instrumentation hook, since the team recommends API endpoint wrappers over instrumentation for reliability.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_PqPIdMg6rpcEgFHdK9SGzg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">@highlight-run/node 3.4.x: Dynamic require of async_hooks is not supported <span>— Vectle</span></a>