-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK fails in ESM mode in combination with date-fns #12154
Comments
Interesting, I wonder why the loader triggers this 🤔 Do you just have only the If you add this before globalThis._sentryEsmLoaderHookRegistered = true |
I'm having the same issue (just with a different import name) and adding this line fixes it for me. |
Be aware that |
ps. Upgrading our web frontends was a breeze, amazing work on v8! |
It looks like this is caused by Do you know what |
Edit: My apologies, I just realized you asked about my import, not
|
I'm observing identical errors when adding The error also occurs for |
I'm running into the exact same error with date-fns v3. Disabling the instrumentation with |
There are outstanding PRs for There is a patch available here that can be used with |
@timfish After sheepishly having to ask ChatGPT how to apply this patch, I can confirm, it works 🎉 👍 . |
Hello, we've just released v8.8.0, which should hopefully resolve this ESM problem. Let us know if you updated and are still running into problems! |
I can confirm that this issue is now resolved! Thank you for taking so much time to work on and coordinate this fix across sentry, OTEL, and Unfortunately we're now running into an issue with the |
resolves #12242 (although there are still some follow ups) https://github.com/open-telemetry/opentelemetry-js/releases/tag/v1.25.0 I think this lockfile looks correct, but lmk if this feels off. resolves #12011 resolves #12059 resolves #12154 resolves #12237 resolves nodejs/import-in-the-middle#77 cc @mohd-akram
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.2.1
Framework Version
Nodejs 20.13.1
Link to Sentry event
https://mycopilot.sentry.io/issues/5344731586/?project=6067364&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=24h&stream_index=0
SDK Setup
Steps to Reproduce
--import ./dist/instrument.js
to thenode
commandExpected Result
Application starts up.
Actual Result
Application crashes with an error which seems to involve duplicate exports with ESM. An example of my particular error:
SyntaxError: Identifier '$longFormatters' has already been declared at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:169:18) at callTranslator (node:internal/modules/esm/loader:272:14) at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:278:30)
Upon investigating, I found my error to be related to the
date-fns
package and this issue. Revertingdate-fns
to a version without a duplicate export results in another similar error (I suspect related to theopenai
package duplicate export though haven't confirmed).This issue does not occur when using the
--import
flag to load a file without sentry code in it, and it doesn't surface elsewhere. This error may be due to other projects misusing ESM, though I hope since the issue only surfaces with Sentry instrumentation that it may be solvable here.The text was updated successfully, but these errors were encountered: