sentry-javascript
sentry-javascript copied to clipboard
Version 7.95.0 introduces breaking change due to type error
Is there an existing issue for this?
- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- [X] I have reviewed the documentation https://docs.sentry.io/
- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/serverless
SDK Version
7.95.0
Framework Version
No response
Link to Sentry event
No response
SDK Setup
No response
Steps to Reproduce
- Set @sentry/serverless version to 7.95.0
- Run ts-node-dev
- Try executing your lambda
Expected Result
Nothing, no reason why this should occur, its a type error from what I can tell. Reverting to 7.66.0 resolves the issue.
Actual Result
Hi @VictrixHominum thanks for writing in!
Please make sure that all your installed @sentry/*
packages are on exactly the same version.
spanContext
is a new function defined on the Span
class and interface. It's exported from @sentry/core
which is a dependency of @sentry/node
and @sentry/serverless
. I'm quite sure that @sentry/core
or @sentry/types
weren't updated correctly to 7.95.0 which would explain the issue.
Please let us know if the issue still persists if all package versions align.
Probably related: I also ran into a type error.
https://unpkg.com/browse/@sentry/[email protected]/
- Package depends on "@sentry/node" version "7.95.0".
- File types/server/httpIntegration.d.ts contains
import("@sentry/node/build/types/integrations")
- That version of "@sentry/node" does not include that file (no build folder in the package root).
It looks like there is a spurious 'build/' folder in the import path that does not exist.
Hmm I'm not sure how this is related but definitely looks like a bug. Not sure why TS would declare the type like this but I'll take a look how we can fix this. Thanks for investigating!
@wereHamster we released v7.98.0 which should fix the issue you reported. I'm going to leave this issue open to give @VictrixHominum a chance to reply if aligning package version fixed their error.
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 remove the label Waiting for: Community
, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Hi @VictrixHominum thanks for writing in!
Please make sure that all your installed
@sentry/*
packages are on exactly the same version.
spanContext
is a new function defined on theSpan
class and interface. It's exported from@sentry/core
which is a dependency of@sentry/node
and@sentry/serverless
. I'm quite sure that@sentry/core
or@sentry/types
weren't updated correctly to 7.95.0 which would explain the issue.Please let us know if the issue still persists if all package versions align.
Hi. I've got the same issue. According to Your suggestions I've checked @sentry/core
and @sentry/types
versions and found they're matching. I have a single copy of each sentry package nothing comes from the nested deps.
I'm trying 7.102.0, the version currently working is 7.91.0
P.S. I'm using @sentry/nextjs integration
@johnsmith-gooddollar Would you be able to provide a reproduction example? Thanks!
@lforst https://good-wallet-v2-git-bump-sentry-7-102-1-gooddollarteam.vercel.app/
source code here: https://github.com/GoodDollar/GoodWalletV2/blob/bump-sentry-7-102-1/apps/wallet/package.json#L13 https://github.com/GoodDollar/GoodWalletV2/blob/bump-sentry-7-102-1/apps/wallet/config.ts#L28 https://github.com/GoodDollar/GoodWalletV2/blob/bump-sentry-7-102-1/apps/wallet/sentry.client.config.ts
To reproduce a) open website root (exactly root, not a /home or any other path) b) first time you need log in via Google (we will enable access soon) c) Open "GoodDollar" in the "apps" carousel d) see console
@johnsmith-gooddollar Thank you! It looks like I don't have access to the repository you shared. Would you mind turning it public or adding me? Otherwise debugging this is gonna be hard (to impossible).
{
"name": "wallet",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev -p 3000",
"build": "next build",
"start": "next start -p 80",
"lint": "next lint"
},
"dependencies": {
"@lottiefiles/react-lottie-player": "^3.5.3",
"@sentry/integrations": "^7.102.1",
"@sentry/nextjs": "^7.102.1",
"analytics-react": "*",
"ethers": "^6.10.0",
"ethers-utils-react": "*",
"gooddollar": "*",
"gooddollar-react": "*",
"ipfs-utils": "*",
"jotai": "^2.6.4",
"lodash": "^4.17.21",
"logger": "*",
"login": "*",
"login-react": "*",
"news-stream": "*",
"news-stream-react": "*",
"next": "^14.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-jazzicon": "^1.0.4",
"react-swipeable": "^7.0.1",
"swr": "^2.2.4",
"tokens-react": "*",
"ui": "*",
"usehooks-ts": "^2.12.1"
},
"devDependencies": {
"@types/node": "^20.8.10",
"@types/react": "^18.2.53",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.17",
"eslint-config-custom": "*",
"postcss": "^8.4.33",
"react-icons": "4.12.0",
"tailwind-config": "*",
"tailwindcss": "^3.4.1",
"tokens": "*",
"tsconfig": "*",
"typescript": "^5.3.3"
}
}
/* eslint-disable turbo/no-undeclared-env-vars */
"use client"
// ...
const sentryConfig = {
//Omitting NEXT_PUBLIC_SENTRY_DSN will disable Sentry silently
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
replaysOnErrorSampleRate: Number(
process.env.NEXT_PUBLIC_SENTRY_REPLAY_ON_ERROR_SAMPLE_RATE ?? 1.0,
),
replaysSessionSampleRate: Number(
process.env.NEXT_PUBLIC_SENTRY_REPLAY_SESSION_SAMPLE_RATE ?? 0.1,
),
tracesSampleRate: Number(
process.env.NEXT_PUBLIC_SENTRY_TRACES_SAMPLE_RATE ?? 1,
),
environment: env,
}
// ...
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/
import * as Sentry from "@sentry/nextjs"
import { CaptureConsole, HttpClient } from "@sentry/integrations"
import { config } from "./config"
Sentry.init({
...config.sentryConfig,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
integrations: [
// Catches fetch errors
new HttpClient({
failedRequestStatusCodes: [
[400, 499],
[500, 599],
],
failedRequestTargets: [/.*/],
}),
new Sentry.Replay({
maskAllText: false,
blockAllMedia: true,
}),
// Catpures console output
new CaptureConsole({
levels: ["error"],
}),
],
// This option is required for capturing headers and cookies.
sendDefaultPii: true,
})
@johnsmith-gooddollar What versions of your Sentry dependencies show in your lockfile? Can you try hardpinning the Sentry dependencies (ie removing ^
)? Thanks.
@johnsmith-gooddollar What versions of your Sentry dependencies show in your lockfile? Can you try hardpinning the Sentry dependencies (ie removing
^
)? Thanks.
we do not have multiple versions:
cat yarn.lock | grep @sentry
"@sentry-internal/feedback@npm:7.102.1":
resolution: "@sentry-internal/feedback@npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry-internal/replay-canvas@npm:7.102.1":
resolution: "@sentry-internal/replay-canvas@npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/replay": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry-internal/tracing@npm:7.102.1":
resolution: "@sentry-internal/tracing@npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/browser@npm:7.102.1":
resolution: "@sentry/browser@npm:7.102.1"
"@sentry-internal/feedback": "npm:7.102.1"
"@sentry-internal/replay-canvas": "npm:7.102.1"
"@sentry-internal/tracing": "npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/replay": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/cli@npm:^1.77.1":
resolution: "@sentry/cli@npm:1.77.1"
"@sentry/core@npm:7.102.1":
resolution: "@sentry/core@npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/integrations@npm:7.102.1, @sentry/integrations@npm:^7.102.1":
resolution: "@sentry/integrations@npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/nextjs@npm:^7.102.1":
resolution: "@sentry/nextjs@npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/integrations": "npm:7.102.1"
"@sentry/node": "npm:7.102.1"
"@sentry/react": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/vercel-edge": "npm:7.102.1"
"@sentry/webpack-plugin": "npm:1.21.0"
"@sentry/node@npm:7.102.1":
resolution: "@sentry/node@npm:7.102.1"
"@sentry-internal/tracing": "npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/react@npm:7.102.1":
resolution: "@sentry/react@npm:7.102.1"
"@sentry/browser": "npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/replay@npm:7.102.1":
resolution: "@sentry/replay@npm:7.102.1"
"@sentry-internal/tracing": "npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/types@npm:7.102.1":
resolution: "@sentry/types@npm:7.102.1"
"@sentry/utils@npm:7.102.1":
resolution: "@sentry/utils@npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/vercel-edge@npm:7.102.1":
resolution: "@sentry/vercel-edge@npm:7.102.1"
"@sentry-internal/tracing": "npm:7.102.1"
"@sentry/core": "npm:7.102.1"
"@sentry/types": "npm:7.102.1"
"@sentry/utils": "npm:7.102.1"
"@sentry/webpack-plugin@npm:1.21.0":
resolution: "@sentry/webpack-plugin@npm:1.21.0"
"@sentry/cli": "npm:^1.77.1"
"@sentry/types": ^7.x
"@sentry/types":
"@sentry/types": ^7.x
"@sentry/types":
"@sentry/integrations": "npm:^7.102.1"
"@sentry/nextjs": "npm:^7.102.1"
@lforst Yes I tried to set exact version by removing ^
and even used Yarn's resolutions
- nothing of those helped, lockfile actually haven't chnaged
@johnsmith-gooddollar I am starting to run out of ideas... Does it also happen in an incognito tab without any browser extensions?
Yes @lforst
@johnsmith-gooddollar would you mind adding me to your repro repo so I can troubleshoot this?
@lforst need to discuss with project owner, just wrote him, awaiting for response
@lforst cannot add you by this moment. have you tried to create empty nextJS project with the following config ? Does it reproduce ?
After some debugging I found the issue appears with sending auto.navigation.browser
and auto.pageload.browser
.
a strange object (not a Span or its descendants without .spanContex()
method) is passed to spanToTraceContext
In the other cases (when it works) that's Transaction
or IdleTransaction
@lforst disabling browser tracing solves the issue. but we need it, so it would be good to have some proper solution
have you tried to create empty nextJS project with the following config ? Does it reproduce ?
@johnsmith-gooddollar I tried and for me, everything compiles and doesn't throw when running it.
Can you check that you do not have any other sentry instances on your page? How often is the initialization logged when you set debug: true
.
Also, can you share what __SENTRY__.hub._version
prints when you paste it into the console? Thanks!
Please also try the latest version 7.108.0
and delete your node_modules
and .next
folder before you build your app.
@lforst ok I will check it at Monday
@lforst new version doesn't work at all, erroring on any event. I'm reverting back
see logs localhost-1711387437778.log
@lforst I was able to run 7.108.0 by
- reverting lockfile to master's version then running yarn
- removing all overrides over browserTracing integration
- removing tracesSampleRate config setting (instead of setting to 0)
if set tracesSampleRate to any value, the error starts reproducing
@johnsmith-gooddollar Not setting tracesSampleRate
is effectively disabling performance monitoring and we will not be hitting the code path that throws. Honestly I don't know what's wrong here and I am out of ideas so we will need a reproduction example to debug this further.
@lforst ok
@johnsmith-gooddollar sorry, with reproduction example I meant code that reproduces this bug which we can actually look at. I should have been more clear. My bad!
@johnsmith-gooddollar I scanned your bundle for instances of "sentry" and found that two dependencies seem to use it. @torusresearch
seems to use it but at least correctly. The @hcaptcha
deps seem to do bad stuff and even seems to have a sentry
option to turn their interfering sentry instance off.
I did the following and the error went away:
<HCaptcha
sentry={false}
...
/>
I'll remember in the future to also ask users to scan their built bundles for funky looking instances of sentry usage - even though that is usually a bit harder to spot.
@lforst Thank you very much!
I had the same problem with HCaptcha and thank you for helping me.