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/sveltekit throws JS parsing error when added to vite.config.js #12032

Open
3 tasks done
selfagency opened this issue May 14, 2024 · 5 comments
Open
3 tasks done

Comments

@selfagency
Copy link

selfagency commented May 14, 2024

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/svelte

SDK Version

8.0.0 but also happens when I downgrade to 7.114.0.

Framework Version

Sveltekit 2.0.0

Link to Sentry event

No response

SDK Setup

import { sentrySvelteKit } from '@sentry/sveltekit';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
  plugins: [
    sentrySvelteKit({
      sourceMapsUploadOptions: {
        org: 'cnyric',
        project: 'supplies-frontend',
      },
    }),
    sveltekit(),
  ],
  test: {
    include: ['src/**/*.{test,spec}.{js,ts}'],
  },
});

Steps to Reproduce

I followed the directions here: https://docs.sentry.io/platforms/javascript/guides/sveltekit/#compatibility. Then I started my app in dev mode and it instantly crashed.

Expected Result

For my application to not crash. If I comment out the sentrySvelteKit block in the vite.config.js everything works fine.

Actual Result

SyntaxError: Unexpected token, expected "}" (17:42)
    at constructor (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:351:19)
    at V8IntrinsicMixin.raise (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3281:19)
    at V8IntrinsicMixin.unexpected (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3301:16)
    at V8IntrinsicMixin.expect (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:3605:28)
    at V8IntrinsicMixin.jsxParseExpressionContainer (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:6702:10)
    at V8IntrinsicMixin.jsxParseElementAt (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:6776:36)
    at V8IntrinsicMixin.jsxParseElement (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:6814:17)
    at V8IntrinsicMixin.parseExprAtom (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:6824:19)
    at V8IntrinsicMixin.parseExprAtom (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:10111:45)
    at V8IntrinsicMixin.parseExprSubscripts (/home/[email protected]/dev/supplies_project/supplies_redux/node_modules/.pnpm/@[email protected]/node_modules/@babel/parser/lib/index.js:10607:23
@Lms24
Copy link
Member

Lms24 commented May 14, 2024

Hey @selfagency thanks for writing in!

Did you upgrade from version 7 of the SDK or start fresh with version 8.0.0?

I'm not yet sure this is the actual cause but this could be related to our auto instrumentation feature of load functions. Can you disable auto instrumentation and try again? Let's see if this is it.

@selfagency
Copy link
Author

selfagency commented May 14, 2024

@Lms24 I started fresh with 8.0.0.

It also did not like that change. Same error as before.

(Posted the wrong error message in the first version of this reply.)

@Lms24
Copy link
Member

Lms24 commented May 14, 2024

Hmm I wonder what else is causing this then... also do you have an idea where this syntax error is actually occurring?

My guess was that our auto instrumentation which modifies some of your files during building causes this. But apparently it's not. Not sure if it helps but you could try disabling source maps upload? But iirc, this shouldn't even be active in dev mode...

Does this only affect dev mode or also npm run build?

@selfagency
Copy link
Author

@Lms24 This works though is obviously not ideal:

    sentrySvelteKit({
      autoInstrument: false,
    }),

@lforst
Copy link
Member

lforst commented May 14, 2024

@selfagency Can you make out from the error logs where exactly (or what syntax) the parser is crashing at? It would be ideal if you could share the relevant code snippet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Development

No branches or pull requests

4 participants