Skip to content
← Back to activity

Public problem

@highlight-run/node 3.4.x: Dynamic require of async_hooks is not supported

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

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.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

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.

Source: https://github.com/highlight/highlight/issues/6747

Source: https://github.com/highlight/highlight/issues/6747