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 gives me the error: "An error occurred on the client side: TypeError: Cannot read properties of undefined (reading 'getIntegrationById')" #8290

Closed
3 tasks done
alexbjorlig opened this issue Jun 5, 2023 · 6 comments · Fixed by #8381
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug

Comments

@alexbjorlig
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/sveltekit

SDK Version

7.54.0

Framework Version

1.20.1

Link to Sentry event

No response

SDK Setup

hooks.client.ts

Sentry.init({
        dsn: config.sentryDsn,
        integrations: [new Sentry.Integrations.Breadcrumbs({ console: false })],
        tracesSampleRate: 0.01,
        release: revision
})

hooks.server.ts

Sentry.init({
        dsn: config2().sentry.dsn,
        environment: config2().sentry.environment,
        release: process.env['VERCEL_GIT_COMMIT_SHA'],
})

Steps to Reproduce

When running my applications e2e test with playwright, I get this error:

An error occurred on the client side: TypeError: Cannot read properties of undefined (reading 'getIntegrationById')
    at instrumentSvelteKitFetch (http://localhost:5100/node_modules/.vite/deps/@sentry_sveltekit.js?v=8db7b1bd:15107:44)
    at Object.apply (http://localhost:5100/node_modules/.vite/deps/@sentry_sveltekit.js?v=8db7b1bd:15086:16)
    at load_node (http://localhost:5100/@fs/Users/alexbjorlig/Documents/eddystone/node_modules/@sveltejs/kit/src/runtime/client/client.js?v=8db7b1bd:525:40)
    at async Promise.all (index 2)
    at async Object._hydrate (http://localhost:5100/@fs/Users/alexbjorlig/Documents/eddystone/node_modules/@sveltejs/kit/src/runtime/client/client.js?v=8db7b1bd:1753:20)
    at async Module.start (http://localhost:5100/@fs/Users/alexbjorlig/Documents/eddystone/node_modules/@sveltejs/kit/src/runtime/client/start.js:22:3) {url: URL, params: Object, route: Object}

Expected Result

No issues with import * as Sentry from '@sentry/sveltekit';

Actual Result

The error An error occurred on the client side: TypeError: Cannot read properties of undefined (reading 'getIntegrationById')

CleanShot 2023-06-05 at 22 03 19@2x

@lforst
Copy link
Member

lforst commented Jun 6, 2023

Hey, can you check (in your lockfile) that all your sentry dependencies are on the same version? Thanks!

@madeleineostoja
Copy link

madeleineostoja commented Jun 22, 2023

I'm also seeing this — I'm working in a monorepo using pnpm, I only have @sentry/sveltekit@^7.56.0 installed, and my lockfile says that is indeed the version that's installed everywhere. However it has some deps that are resolving to 7.48.0, namely @sentry/bundler-plugin-core@0.6.0 is pulling in @sentry/tracing@7.48.0, which in turn pulls in core, types, utils, all at 7.48.0. I can share my whole lockfile if that helps.

This is a prod-breaking issue for me that I only got when upgrading all my deps so some insight or further debugging steps would be wonderful.

@Lms24
Copy link
Member

Lms24 commented Jun 22, 2023

Hi @alexbjorlig and @madeleineostoja, thanks for reporting this. We missed a crucial edge case here - namely the client being undefined. I opened #8381 to fix this.

Lms24 added a commit that referenced this issue Jun 22, 2023
…s valid (#8381)

In the client-side SvelteKit fetch instrumentation, our previous type
cast when retrieving the SDK client was wrong, causing us to not guard
the fetch instrumentation correctly if the client was undefined. This fix
adds an undefined check.

fixes #8290
@Amy-B-Tradition
Copy link

Looking at the Javascript code, there doesn't even seem to be a getIntegrationById. Instead, there's a getIntegrationByName

@Lms24
Copy link
Member

Lms24 commented Jan 26, 2024

Hey @Amy-B-Tradition please open a new issue if you're experiencing a problem. This one's quite old by now and we're changing some things within the SDK for our upcoming major.

@Amy-B-Tradition
Copy link

Hey @Amy-B-Tradition please open a new issue if you're experiencing a problem. This one's quite old by now and we're changing some things within the SDK for our upcoming major.

I resolved the issue by storing the replay instance I created in Redux. Not the best solution, but since your documentation on how to get the replay instance from anywhere was incorrect it seemed the best choice. I've resolved the issue for myself, but other users may benefit if you fix your docs. Because I'm "on the clock" and the issue is resolved, I am not going to open an issue for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: sveltekit Issues related to the Sentry SvelteKit SDK Type: Bug
Projects
Archived in project
5 participants