Skip to content
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

profiling-node should not shim cjs globals #13259

Closed
mbrevda opened this issue Aug 7, 2024 · 10 comments · Fixed by #13267
Closed

profiling-node should not shim cjs globals #13259

mbrevda opened this issue Aug 7, 2024 · 10 comments · Fixed by #13267

Comments

@mbrevda
Copy link

mbrevda commented Aug 7, 2024

(sorry, the regular templates weren't working for me - github was returning an ambiguous error).

As I try updating to v8 (8.24.0), I'm encountering an issue where profiling-node tries to shim cjs globals without first checking if they are set. This is done via the @rollup/plugin-esm-shim package in the rollup config, resulting in some cjs specific globals being injected even if they are already defined (see lines 19-21).

This is an issue because some bundlers require defining these globals manually (where they require defining the cjs globals), causing the Sentry variables to error with SyntaxError: Identifier '__filename' has already been declared

I'd expect

that Sentry should not define global variables. If these variables are crucial and there is no other way to define them, respectfully check if they are set before defining them.

var __filename = cjsUrl.fileURLToPath(import.meta.url);
   ^

SyntaxError: Identifier '__filename' has already been declared
   at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
   at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:163:18)
   at callTranslator (node:internal/modules/esm/loader:430:14)
   at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:436:30)

Thanks!

@andreiborza
Copy link
Member

Hi, thanks for writing in. I've kicked this up to the respective team, but generally I'd agree we should guard against this.

We'll take a look.

@JonasBa
Copy link
Member

JonasBa commented Aug 7, 2024

@mbrevda thanks for opening the issue, the SDK should indeed handle this. I'm making the change to only conditionally apply the shims and will try and get it merged asap so it can go out with the next minor release

@mbrevda
Copy link
Author

mbrevda commented Aug 7, 2024

Awesome, looking forward. Thanks for the quick reply!

@mbrevda
Copy link
Author

mbrevda commented Sep 2, 2024

hi - how's this coming along?

@s1gr1d
Copy link
Member

s1gr1d commented Sep 4, 2024

Hello @mbrevda, we currently have a PR for this: #13267

@mbrevda
Copy link
Author

mbrevda commented Sep 4, 2024

Thanks, any idea what the hold is there?

@Lms24
Copy link
Member

Lms24 commented Sep 5, 2024

Hi, the PR is still under review. Not entirely sure about specifics there but @AbhiPrasad took a look yesterday. Feel free to subscribe to this issue as it's gonna be closed once the PR gets merged.

@JonasBa
Copy link
Member

JonasBa commented Sep 9, 2024

@mbrevda sorry I was ooo last week, let me take a look at this now.

@JonasBa
Copy link
Member

JonasBa commented Sep 9, 2024

@mbrevda PR is ready and CI is passing. We'll get this merged tomorrow and ship it with the next release, sorry for the wait!

@AbhiPrasad
Copy link
Member

Fix released with https://github.com/getsentry/sentry-javascript/releases/tag/8.30.0 - thanks for your patience everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants