Repository navigation
Unable to initialize Sentry SDK - "utils_1.PromiseBuffer is not a constructor" #5116
Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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
Lms24 commentedon May 17, 2022
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
simmons-kyle commentedon May 18, 2022
Hey @Lms24 - here's the options object we pass to our
Sentry.initcall:Is there anything there that could cause any red flags? We've verified that the values stored within variables (i.e. the
configobject for SENTRY_DSN, APP_BUILD, APP_ENV andsampleRate) are present and correct too.EDIT - We are now seeing a slightly different error on other functions that consume the same
Sentry.initcall (even when using the package version I suspected resolved this issue). This time it relates toutils_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)`
Lms24 commentedon May 18, 2022
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
DSNclass 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/nodedepends on other Sentry pacakges, such as@sentry/coreor@sentry/utils. Those versions must match. Also, do you have@sentry/tracinginstalled? 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.
simmons-kyle commentedon May 18, 2022
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.