You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Browser lib contains variable "chrome" that conflicts with the global "chrome" variable #6880
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: isProduction ? 0.5 : 1.0,
});
Steps to Reproduce
Import sentry into script
Load script in browser
Expected Result
No conflicting variable
Actual Result
Uncaught SyntaxError: Identifier 'chrome' has already been declared
changed the title [-]Browser lib contains variable chrome that conflicts with the global chrome variable[/-][+]Browser lib contains variable "chrome" that conflicts with the global "chrome" variable[/+]on Jan 19, 2023
The chrome declaration is not being exported, so I don't know how it ends up in your final bundle since the bundler should be isolating it to it's own lexical scope. I think there is something weird happening with your final bundle that gets generated, maybe it's something to do with nodeResolve?
Maybe you have to dedupe your sentry imports if there are duplicates appearing?
From looking around I can only see UI5/webcomponents#4978 which hit a similar problem (also with rollup).
Do you know what else in your app could be declaring a global chrome object? If you can probably find this by searching through your final generated bundle.
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Could you please review link from @wesleyyee where chrome: is defined. We also had issue with Vite option that disables identifier minification that raised "chrome" conflict with global chrome variable
Activity
[-]Browser lib contains variable chrome that conflicts with the global chrome variable[/-][+]Browser lib contains variable "chrome" that conflicts with the global "chrome" variable[/+]AbhiPrasad commentedon Jan 19, 2023
Hey @wesleyyee, thanks for writing in. I tried to reproduce this, but was unable to: https://codesandbox.io/s/global-chrome-variable-config-jpu1bm?file=/src/index.js. Could you give some details about how you are bundling you application, and what your bundler config looks like?
It would be great if you could provide a reproduction of this issue to help us debug further.
wesleyyee commentedon Jan 19, 2023
Thanks @AbhiPrasad we are using rollup to bundle and the config looks like
wesleyyee commentedon Jan 19, 2023
this seems to be the variable that collides with the global chrome object
https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/stack-parsers.ts#L37
AbhiPrasad commentedon Jan 19, 2023
The
chromedeclaration is not being exported, so I don't know how it ends up in your final bundle since the bundler should be isolating it to it's own lexical scope. I think there is something weird happening with your final bundle that gets generated, maybe it's something to do withnodeResolve?Maybe you have to dedupe your sentry imports if there are duplicates appearing?
From looking around I can only see UI5/webcomponents#4978 which hit a similar problem (also with rollup).
Do you know what else in your app could be declaring a global chrome object? If you can probably find this by searching through your final generated bundle.
github-actions commentedon Feb 10, 2023
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it
Status: BacklogorStatus: In Progress, I will leave it alone ... forever!"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
dmajkic commentedon Feb 29, 2024
Could you please review link from @wesleyyee where chrome: is defined. We also had issue with Vite option that disables identifier minification that raised "chrome" conflict with global chrome variable
mydea commentedon Feb 29, 2024
This link: https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/stack-parsers.ts#L37 does not lead to anything chrome related anymore. If you're still seeing an issue, could you open a new issue with as much info as possible, so we can take a look at reproducing/fixing the issue? thank you!
dmajkic commentedon Feb 29, 2024
Line 61:
https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/stack-parsers.ts#L61
This was from logs: processed js received on browser side, where we got error:

AbhiPrasad commentedon Mar 1, 2024
This is breaking my brain a little bit, but to unblock I opened #10874 - but I think that is not the long term solution.
@dmajkic mind elaborating why you're doing this? It does increase bundle size substantially.
fix(browser): Don't use chrome variable name (#10874)
fix(browser): Don't use chrome variable name (#10874)
AbhiPrasad commentedon Mar 8, 2024
Released https://github.com/getsentry/sentry-javascript/releases/tag/7.106.0 which should address this.