sentry-javascript: Breaking API change between patch update of @sentry/tracing 6.0.2 to 6.0.3

Package + Version

  • @sentry/browser 6.0.2
  • @sentry/tracing 6.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

Most upvoted comments

We have a strict version requirement in package.json file of every package we release

I appreciate that but still, when i come to Sentry and see this:

image

… and stupidly follow the documentation linked in that box, i end up with

"@sentry/react": "^6.4.1",
"@sentry/tracing": "^6.3.5",

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.

So the current fix is to update the documentation? No plan to find a way to enforce it via package managers? Or even rethink version bumps to avoid such breaks?

Correct, not in this major version (v6).

Maybe you should at least add some kind of peerDependencies between those to ensure your users will not pull them at incompatible versions.

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. optionalDependencies are opt-out not opt-in, so they are not much better than regular dependencies field. What we want to mitigate, is installing @sentry/browser for node users, and @sentry/node for browser users, yet somehow enforce correct version resolution.