sentry-javascript: Breaking API change between patch update of @sentry/tracing 6.0.2 to 6.0.3
- Review the documentation: https://docs.sentry.io/
- Search for existing issues: https://github.com/getsentry/sentry-javascript/issues
- Use the latest release: https://github.com/getsentry/sentry-javascript/releases
- Provide a link to the affected event from your Sentry account
Package + Version
-
@sentry/browser6.0.2 -
@sentry/tracing6.0.3
Version:
6.0.3
Description
Latest patch version bump of @sentry/tracing from 6.0.2 to 6.0.3 broke our CI due to a type incompatibility. It seems this is caused by #3192 that introduces new non-optional methods in exported type Span. As a consequence 6.0.3 is not compatible with version 6.0.2 of related packages (in our case @sentry/browser) and single package updates through Dependabot isn’t possible anymore. Initializing Sentry with mixed 6.0.2 + 6.0.3 versions results in following compilation error:
Sentry.init({
// ...
integrations: [new Integrations.BrowserTracing()],
// ...
});
src/index.tsx:18:20 - error TS2322: Type 'BrowserTracing' is not assignable to type 'Integration'.
Types of property 'setupOnce' are incompatible.
Type '(_: (callback: EventProcessor) => void, getCurrentHub: () => Hub) => void' is not assignable to type '(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub) => void'.
Types of parameters '_' and 'addGlobalEventProcessor' are incompatible.
Types of parameters 'callback' and 'callback' are incompatible.
Type 'import("C:/.../node_modules/@sentry/types/dist/eventprocessor").EventProcessor' is not assignable to type 'import("C:/.../node_modules/@sentry/browser/node_modules/@sentry/types/dist/eventprocessor").EventProcessor'.
Types of parameters 'event' and 'event' are incompatible.
Type 'import("C:/.../node_modules/@sentry/browser/node_modules/@sentry/types/dist/event").Event' is not assignable to type 'import("C:/.../node_modules/@sentry/types/dist/event").Event'.
Types of property 'spans' are incompatible.
Type 'import("C:/.../node_modules/@sentry/browser/node_modules/@sentry/types/dist/span").Span[] | undefined' is not assignable to type 'import("C:/.../node_modules/@sentry/types/dist/span").Span[] | undefined'.
Type 'import("C:/.../node_modules/@sentry/browser/node_modules/@sentry/types/dist/span").Span[]' is not assignable to type 'import("C:/.../node_modules/@sentry/types/dist/span").Span[]'.
Type 'Span' is missing the following properties from type 'Span': toContext, updateWithContext
18 integrations: [new Integrations.BrowserTracing()],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Interface Span is a public exported interface shared between multiple packages, therefore adding non-optional methods to it should probably be considered as a major version change instead of patch to comply with semver.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- fix sentry update issues See also: https://github.com/getsentry/sentry-javascript/issues/3223 — committed to ariccio/COVID-CO2-tracker by ariccio 3 years ago
I appreciate that but still, when i come to Sentry and see this:
… and stupidly follow the documentation linked in that box, i end up with
in my
package.json, triggering the same TS issue that brought me here.Maybe adding a proper update documentation page would avoid some lost time for both sides 👌
@TooColline glad to hear. Thanks for letting us know!
This is still happening for @sentry/tracing 7.2.0. I’m using @sentry/vue and typescript is complaining of the same cc @kamilogorek
Thanks @tsadiq, we’ll look at it and see what we can do 😉
@clinejj see https://github.com/getsentry/sentry-javascript/issues/3221#issuecomment-771069696 (it was caused due to misused event listener method in the end-users code)
Hey, @lforst you were right, had to confirm the yarn.lock file and found @sentry/tracing on the 7.1.1 version. It’s all good now, thank you.
Correct, not in this major version (v6).
Agree, although there’s one problem with that based on my tests. When dependency is marked as
peer, it will emit warning, and may break build in some configurations. There’s a way around that, by adding"peerDependenciesMeta": { "@sentry:browser": { "optional": true } }for example, but then, it doesn’t enforce the correct version resolution in either yarn or npm.optionalDependenciesareopt-outnotopt-in, so they are not much better than regulardependenciesfield. What we want to mitigate, is installing@sentry/browserfor node users, and@sentry/nodefor browser users, yet somehow enforce correct version resolution.