Skip to content

Unable to initialize Sentry SDK - "utils_1.PromiseBuffer is not a constructor" #5116

Closed

Description

@simmons-kyle

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

6.19.7

Framework Version

6.19.7

Link to Sentry event

No response

Steps to Reproduce

When running up an Azure function that initializes Sentry to capture any potential exceptions, the function fails to load - throwing the following exception:

'TypeError: utils_1.PromiseBuffer is not a constructor' Stack: TypeError: utils_1.PromiseBuffer is not a constructor at HTTPSTransport.BaseTransport (D:\home\site\wwwroot\node_modules\@sentry\node\dist\transports\base.js:20:24) at new HTTPSTransport (D:\home\site\wwwroot\node_modules\@sentry\node\dist\transports\https.js:11:28) at NodeBackend._setupTransport (D:\home\site\wwwroot\node_modules\@sentry\node\dist\backend.js:55:16) at NodeBackend.BaseBackend (D:\home\site\wwwroot\node_modules\@sentry\core\dist\basebackend.js:18:32) at new NodeBackend (D:\home\site\wwwroot\node_modules\@sentry\node\dist\backend.js:15:42) at NodeClient.BaseClient (D:\home\site\wwwroot\node_modules\@sentry\core\dist\baseclient.js:52:25) at new NodeClient (D:\home\site\wwwroot\node_modules\@sentry\node\dist\client.js:32:24) at Object.initAndBind (D:\home\site\wwwroot\node_modules\@sentry\core\dist\sdk.js:27:18) at Object.init (D:\home\site\wwwroot\node_modules\@sentry\node\dist\sdk.js:116:12)

Expected Result

Expected that the Sentry.init({...}) (where Sentry is set via Sentry = require("@sentry/node")) call initialises our Sentry instance based on the provided config.

Actual Result

The following exception is thrown upon calling Sentry.init({...}):

'TypeError: utils_1.PromiseBuffer is not a constructor' Stack: TypeError: utils_1.PromiseBuffer is not a constructor at HTTPSTransport.BaseTransport (D:\home\site\wwwroot\node_modules\@sentry\node\dist\transports\base.js:20:24) at new HTTPSTransport (D:\home\site\wwwroot\node_modules\@sentry\node\dist\transports\https.js:11:28) at NodeBackend._setupTransport (D:\home\site\wwwroot\node_modules\@sentry\node\dist\backend.js:55:16) at NodeBackend.BaseBackend (D:\home\site\wwwroot\node_modules\@sentry\core\dist\basebackend.js:18:32) at new NodeBackend (D:\home\site\wwwroot\node_modules\@sentry\node\dist\backend.js:15:42) at NodeClient.BaseClient (D:\home\site\wwwroot\node_modules\@sentry\core\dist\baseclient.js:52:25) at new NodeClient (D:\home\site\wwwroot\node_modules\@sentry\node\dist\client.js:32:24) at Object.initAndBind (D:\home\site\wwwroot\node_modules\@sentry\core\dist\sdk.js:27:18) at Object.init (D:\home\site\wwwroot\node_modules\@sentry\node\dist\sdk.js:116:12)

I can bypass this issue by using an older version of the SDK (6.16.1).

Activity

  1. Lms24 commented on May 17, 2022

    @Lms24
    Member

    HI @simmons-kyle and thanks for writing in!

    Have you tried reproducing this behaviour with our beta version of v7? If not, I'd recommend installing @sentry/node@7.0.0-beta.1 (beta.2 will be out very soon) and trying if this fixes it. We made a lot of changes to our clients and transports which makes it particularly interesting to see if the problem is still there.

    Also on that note: are you passing any special options to Sentry.ini (e.g. a custom transport, special integrations, etc)?

    Hope this helps

    EDIT: Here's the link to our v7 migration guide

  2. simmons-kyle commented on May 18, 2022

    @simmons-kyle
    Author

    Hey @Lms24 - here's the options object we pass to our Sentry.init call:

    {
        dsn: config.SENTRY_DSN,
        release: config.APP_BUILD,
        environment: config.APP_ENV,
        autoSessionTracking: true,
        attachStacktrace: true,
        // @ts-ignore
        sendDefaultPii: true,
        tracingOptions: {
            trackComponents: true,
        },
        integrations: [
            new Integrations.CaptureConsole({
            levels: ['error'],
            }),
        ],
        tracesSampleRate: sampleRate,
        logErrors: true,
      }
    

    Is there anything there that could cause any red flags? We've verified that the values stored within variables (i.e. the config object for SENTRY_DSN, APP_BUILD, APP_ENV and sampleRate) are present and correct too.

    EDIT - We are now seeing a slightly different error on other functions that consume the same Sentry.init call (even when using the package version I suspected resolved this issue). This time it relates to utils_1.Dsn:

    'TypeError: utils_1.Dsn is not a constructor' Stack: TypeError: utils_1.Dsn is not a constructor at NodeBackend._setupTransport (D:\home\site\wwwroot\node_modules@sentry\node\dist\backend.js:97:19) at NodeBackend.BaseBackend (D:\home\site\wwwroot\node_modules@sentry\core\dist\basebackend.js:15:32) at new NodeBackend (D:\home\site\wwwroot\node_modules@sentry\node\dist\backend.js:15:42) at NodeClient.BaseClient (D:\home\site\wwwroot\node_modules@sentry\core\dist\baseclient.js:53:25) at new NodeClient (D:\home\site\wwwroot\node_modules@sentry\node\dist\client.js:33:24) at Object.initAndBind (D:\home\site\wwwroot\node_modules@sentry\core\dist\sdk.js:18:18) at Object.init (D:\home\site\wwwroot\node_modules@sentry\node\dist\sdk.js:116:12)`

  3. Lms24 commented on May 18, 2022

    @Lms24
    Member

    So, I took a look at the error stack and it seems weird to me that the SDK apparently tries to call constructors that aren't there. So I suspect that you might have some version mismatches in your Sentry packages. For example, the DSN class was removed in #4325 a while ago. Can you check if the versions of your Sentry packages are all the same?

    As an example, @sentry/node depends on other Sentry pacakges, such as @sentry/core or @sentry/utils. Those versions must match. Also, do you have @sentry/tracing installed? If yes, it should have the same version as the Node SDK. We generally strongly recommend to keep all Sentry packages at the same versions to avoid such problems.

    Hope this helps!

    PS: v7 introduces a few more breaking changes, so it's very important to also upgrade all packages to v7 when you're making the switch.

  4. simmons-kyle commented on May 18, 2022

    @simmons-kyle
    Author

    Thanks @Lms24 - yeah we had matching versions for each of our sentry packages, however I believe we have a fix now and it's along the lines of what you suspect. What managed to fix it was removing the node_modules folder entirely and then running yarn (or npm install) again.

    We had some back and forth on our repo with the versions changing and there must have been some dependencies which were out of sync along the way due to that. Having a fresh install seemed to resolve the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions