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

[@sentry/nuxt] GLOBAL_OBJ does not provided #14846

Open
3 tasks done
elya-sidil-ogly opened this issue Dec 27, 2024 · 11 comments
Open
3 tasks done

[@sentry/nuxt] GLOBAL_OBJ does not provided #14846

elya-sidil-ogly opened this issue Dec 27, 2024 · 11 comments
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK

Comments

@elya-sidil-ogly
Copy link

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nuxt

SDK Version

8.47.0

Framework Version

Nuxt 3.15.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. add @sentry/nuxt to project using @sentry/wizard as described in docs
  2. running dev server

Expected Result

running dev server

Actual Result

 ERROR  [worker reload] [worker init] /home/pogos/projects/ticketme/web/widget/.nuxt/dev/index.mjs failed                                                                   6:39:37 PM

  

  [cause]: The requested module 'file:///home/pogos/projects/ticketme/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/cjs/index.js' does not provide an export named 'GLOBAL_OBJ'

      import { dropUndefinedKeys, getTraceMetaTags, GLOBAL_OBJ, vercelWaitUntil, getClient, logger, flush, getIsolationScope, getDefaultIsolationScope, withIsolationScope } from '/home/pogos/projects/ticketme/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/cjs/index.js';
      ^^^^^^^^^^
      SyntaxError: The requested module '/home/pogos/projects/ticketme/node_modules/.pnpm/@[email protected]/node_modules/@sentry/core/cjs/index.js' does not provide an export named 'GLOBAL_OBJ'
      at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)
      at async ModuleJob.run (node:internal/modules/esm/module_job:263:5)
      at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
      at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Dec 27, 2024
@github-actions github-actions bot added the Package: nuxt Issues related to the Sentry Nuxt SDK label Dec 27, 2024
@s1gr1d
Copy link
Member

s1gr1d commented Dec 30, 2024

Hy, thanks for reaching out. Sadly, I am not able to reproduce your issue with pnpm.

In the error message you posted, I can see that version 7.120.0 is used. This is weird and should not be the case. Do you have any other versions of Sentry installed?

Can you pnpm why @sentry/core and post the result here?

@clinton9ice
Copy link

I'm also having the same issue using yarn

The requested module 'file:///Users/emmanuelufere/Documents/dir/node_modules/@sentry/core/cjs/index.js' does not provide an export named 'vercelWaitUntil'
      SyntaxError: The requested module 'node_modules/@sentry/core/cjs/index.js' does not provide an export named 'vercelWaitUntil'
      at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
      at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
      at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
      at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)`

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 20, 2025
@andreiborza
Copy link
Member

hi @clinton9ice, thanks for writing in.

Do you have a reproduction repo where we could try this out? I tried this out with a fresh nuxt project and the wizard and am not running into this.

Could you please paste the output of yarn list @sentry/nuxt?

@clinton9ice
Copy link

hi @clinton9ice, thanks for writing in.

Do you have a reproduction repo where we could try this out? I tried this out with a fresh nuxt project and the wizard and am not running into this.

Could you please paste the output of yarn list @sentry/nuxt?

I will try to recreate this when i'm done with work, but i think the version of @sentry/nuxt: ^8.50.0 was the issue cause i stopped having the error logged to my terminal when i downgraded to "@sentry/nuxt": "^8.48.0". Now everything seems fine and my panel is recording again

@larsvanherk
Copy link

larsvanherk commented Jan 28, 2025

Hey there!

Ran into this problem at work today too, got a small reproduction with Nuxt set up:
https://github.com/larsvanherk/iitm-export-star-repro

Work code's private, so I had to take out the DSN / project details, but otherwise it should immediately trigger the error when you follow the reproduction steps.

During our research, we came across these issues:

Very much suspect it's got something to do with import-in-the-middle still, but upgrading to the versions recommended in those tickets does nothing for us...
Seems like it's something related to export * from './common' in graphql-ws itself.
The file exists in that module, and it does indeed export the GRAPHQL_TRANSPORT_WS_PROTOCOL variable, but the IITM module seems to break and just give up around that area.

Might be useful, but the reason IITM gave for not being able to wrap that specific file was:

cause: TypeError: emitImportAssertionWarning is not a function

For now we've gotten around it by disabling tracing by setting this property in our sentry.server.config.ts:

Sentry.init({
  ...

  registerEsmLoaderHooks: false,

  ...
});

Source / Recommendation: https://docs.sentry.io/platforms/javascript/guides/node/install/esm/#troubleshooting-instrumentation

Ideally we'd like to use Sentry's tracing functionality, but so far no luck in getting it to work...

Will comment again here if something comes up on our end!

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 28, 2025
@mydea
Copy link
Member

mydea commented Jan 28, 2025

Can you instead try this:

Sentry.init({
  // other config
registerEsmLoaderHooks: {
    onlyIncludeInstrumentedModules: true,
  },
});

this should hopefully also fix this. In v9, this will become the default, as it helps prevent issues like these!

@larsvanherk
Copy link

Hey there! Thanks for the fast response!

Will try that today! From what I've read in the docs, that only works if Sentry is loaded with the --import flag, right?
We're currently forced to use autoInjectServerSentry: 'top-level-import', not sure if that option works for that import method as well?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Jan 29, 2025
@mydea
Copy link
Member

mydea commented Jan 29, 2025

Hey there! Thanks for the fast response!

Will try that today! From what I've read in the docs, that only works if Sentry is loaded with the --import flag, right? We're currently forced to use autoInjectServerSentry: 'top-level-import', not sure if that option works for that import method as well?

Hmm, not 100% sure TBH 🤔 it's at least worth a try! Let us know if that worked for you, we may also adjust docs around this then based on this!

@larsvanherk
Copy link

Hey there! Thanks for the fast response!
Will try that today! From what I've read in the docs, that only works if Sentry is loaded with the --import flag, right? We're currently forced to use autoInjectServerSentry: 'top-level-import', not sure if that option works for that import method as well?

Hmm, not 100% sure TBH 🤔 it's at least worth a try! Let us know if that worked for you, we may also adjust docs around this then based on this!

Perfect, pushing it to our test environment today, will report back! Thanks again! 😄

@larsvanherk
Copy link

Had to revert that config, we're getting the same error with the other config...

Not sure if this is more an import-in-the-middle issue or if something more's going on, will continue to research in the next coming weeks...

@timfish
Copy link
Collaborator

timfish commented Jan 30, 2025

I think this might be caused by this bug:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK
Projects
Status: No status
Development

No branches or pull requests

8 participants