Sentry-javascript: Typescript error for RewriteFrames integration with version 5.10.0

Created on 4 Dec 2019  ·  5Comments  ·  Source: getsentry/sentry-javascript

Package + Version

"@sentry/electron": "^1.0.0",
"@sentry/integrations": "^5.10.0",

Description

The code in question:

Sentry.init({
    dsn: sentryDsn,
    beforeSend(event: any) {
        // Check if it is an exception, and if so, show the report dialog
        if (event.exception) {
            console.log(`showing dialog`);
            Sentry.showReportDialog({ eventId: event.event_id });
        }
        return event;
    },
    integrations: [
        new RewriteFrames({
            root: global.__rootdir__,
        }),
    ],
});

With version 5.10.0, I get a typescript error for the integrations field in Sentry.init's config:

Type 'RewriteFrames[]' is not assignable to type 'Integration[] | ((integrations: Integration[]) => Integration[])'.
  Type 'RewriteFrames[]' is not assignable to type 'Integration[]'.
    Type 'RewriteFrames' is not assignable to type 'Integration'.
      Types of property 'setupOnce' are incompatible.
        Type '(addGlobalEventProcessor: (callback: import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/integrations/node_modules/@sentry/types/dist/eventprocessor").EventProcessor) => void, getCurrentHub: () => import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/integrations/node_modules/@sentry/types/dist...' is not assignable to type '(addGlobalEventProcessor: (callback: import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/types/dist/eventprocessor").EventProcessor) => void, getCurrentHub: () => import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/types/dist/hub").Hub) => void'.
          Types of parameters 'addGlobalEventProcessor' and 'addGlobalEventProcessor' are incompatible.
            Types of parameters 'callback' and 'callback' are incompatible.
              Type 'import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/integrations/node_modules/@sentry/types/dist/eventprocessor").EventProcessor' is not assignable to type 'import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/types/dist/eventprocessor").EventProcessor'.
                Types of parameters 'event' and 'event' are incompatible.
                  Type 'import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/types/dist/event").Event' is not assignable to type 'import("/Users/bjaffe/Repos/branch-manager/node_modules/@sentry/integrations/node_modules/@sentry/types/dist/event").Event'.
                    Types of property 'type' are incompatible.
                      Type '"none"' is not assignable to type '"transaction"'.ts(2322)
options.d.ts(33, 5): The expected type comes from property 'integrations' which is declared here on type 'ElectronOptions'

This issue goes away when I downgrade to version 5.8.0

Needs Reproduction

Most helpful comment

It happened to me as well when @sentry/node and @sentry/integrations were not synced up.
In my specific case:

"@sentry/integrations": "^5.4.2",
"@sentry/node": "^5.10.2",

This situation was created following an npm audit fix
Force-updating @sentry/integrations to latest fixed it for me (npm i --save @sentry/integrations)

All 5 comments

Just tried the very same code and it compiles with no issues.

image

There's a chance that some packages dependencies get out of sync (happened few times to some people already) and simply removing all node_modules and reinstalling them fresh usually helped.

If it wont be the case for you, can you provide a small repo with repro-case that I can use?

Got the same, but only on my CI (even with v5.10.1) :/

On CI the node_modules is rebuilt each time I guess this is not solving the issue, but why I can't reproduce on local (even if I remove the node_modules and yarn.lock file), I don't know 🤷‍♂️

It happened to me as well when @sentry/node and @sentry/integrations were not synced up.
In my specific case:

"@sentry/integrations": "^5.4.2",
"@sentry/node": "^5.10.2",

This situation was created following an npm audit fix
Force-updating @sentry/integrations to latest fixed it for me (npm i --save @sentry/integrations)

I'm not sure if this is issue on our side, or on npm/yarn resolving dependencies, but I'm more than happy to reopen the issue if someone will be able to provide concrete repro. Otherwise it's just a guessing game.

It happened to me as well when @sentry/node and @sentry/integrations were not synced up.
In my specific case:

"@sentry/integrations": "^5.4.2",
"@sentry/node": "^5.10.2",

This situation was created following an npm audit fix
Force-updating @sentry/integrations to latest fixed it for me (npm i --save @sentry/integrations)

It's true. Updating @sentry to the latest fixes this issue.

Was this page helpful?
0 / 5 - 0 ratings