-
Notifications
You must be signed in to change notification settings - Fork 35
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
Service Worker "import sentry-release-injection" error when sourcemapping for Sentry (Vite plugin) #460
Comments
Hi, this is probably a bug somewhere in You can point them to this comment. My suspicion here is that they are trying to resolve or rewrite the virtual module which they should generally not do since it starts with a null bye Ideally you also share your build logs in case there are any warnings or similar! |
I also encountered this problem and here is a simple reproduction:
|
@houxg What do you mean exactly by |
create a simple vue3 project by vite, and setup sentry-vite-plugin. |
I am also experiencing this same error. Here are the packages and versions I am working with:
Any tips on how to fix this or is Sentry and vite-pwa not able to work together at this time? |
I haven't tried out vite-pwa in combination with the plugin. If someone provides a minimal reproduction example I can take a look. Otherwise we will look at this when we have some spare cycles which may take a while. |
@lforst Here is a minimal reproduction. I have some instructions on what I did to reproduce the issue in the readme. https://github.com/MaxWeisen/vite-pwa-sentry-plugin-issue Thank you! |
This is a problem in both, workbox-build and sentry when using
We cannot use vite-pwa-plugin and sentry in dev server even when registering the service worker with type module. The workaround is using a custom service worker: in this case, Check from this comment and next ones: vite-pwa/nuxt#132 (comment). Here a working example in dev server and build : https://github.com/userquin/vite-pwa-sentry-plugin-issue-120/tree/inject-manifest (inject-manifest branch) |
I am not an expert in this overall, but could a solution also be to just not run the sentryVitePlugin in dev mode at all? IMHO you probably don't need it in dev mode? |
@mydea the problem is about testing the sw and the pwa web manifest, sentry should have a way to exclude some assets, rn any asset with
EDIT: or just exclude the sentry plugin in dev, it is easy, just adding |
Hmm, I guess we could add some kind of |
EDIT: or just exclude the sentry plugin in dev, it is easy, just adding |
I think we are unlikely to do this in the plugi
I think we are unlikely to do that, if you want this you can simply skip adding the plugin in dev yourself, I guess? Or am I missing something there? I think having an option to ignore certain files for sourcemaps injection is not unreasonable 🤔 I'll wait for @Lms24 & @lforst to chime in as they know more about the deeper internals of the bundler plugins, though. |
@userquin I still firmly believe this is an issue with |
@lforst We cannot also mix This is a limitation on how sw can be registered: rn the workaround is changing the strategy and use custom sw. Since sentry is adding that import to any asset with |
If the Sentry vite plugin causes issues you could always use Sentry CLI to inject debug IDs and upload sourcemaps: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/ Currently, resolving this issue is not a priority for us, since Sentry CLI should work fine as a workaround. If you are down for it you could open a PR with a fix (if you have one in mind). Otherwise, I will backlog this for now. |
I'm using I noticed that all it does is set Would be nice to have an option to configure how the import is injected. |
Hi, if you set So,
Nope, all good :) |
Closing for clean-up. Please re-open the issue if this still applies. Thanks! |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/vue
SDK Version
7.91.0
Framework Version
Vue 3.2.0
Link to Sentry event
No response
SDK Setup
Steps to Reproduce
Expected Result
Not having an import sourcemap error
Actual Result
Console:
Uncaught SyntaxError: Cannot use import statement outside a module (at dev-sw.js?dev-sw:99:2)
File error:
The text was updated successfully, but these errors were encountered: