sentry-javascript: Undefined hub.startSession on v6 upgrade
- 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
- other:
@sentry/react
Version:
6.0.4
Description
I’m getting an error when bumping @sentry/react to v6.0.4:
Uncaught TypeError: hub.startSession is not a function
at startSessionTracking (sdk.ts:221)
at init (sdk.ts:106)
at Module.init (sdk.ts:18)
at Module.<anonymous> (index.tsx:22)
at Module../src/index.tsx (index.tsx:64)
at __webpack_require__ (bootstrap:856)
at fn (bootstrap:150)
at Object.1 (wdyr.js:11)
at __webpack_require__ (bootstrap:856)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1
Debugging this line, hub indeed does not seem to have a startSession function on its prototype.
Disabling autoSessionTracking fixes the issue, but is this expected?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 26 (8 by maintainers)
Same here I get this error
hub.captureSession is not a functionafter updating tov6.2.0. I am using a single Sentry installation on a react project and I don’t have FileStack.edit: I can provide a sentry issue link, I hope this can help https://sentry.io/organizations/mineko-gmbh/issues/2225137133/
We rely on a global
Hubobject, which doesn’t get overwritten by the secondSentry.init()call. If that call is from 6.x, it tries to start a session, and that’s where you run into the problem you’re having. What we tell people to do is to create a second hub, rather than callingSentry.init()again.That said, we are rethinking the hub/client architecture in version 7, which is being worked on now, and we’ll keep this issue in mind as we do.
Hmmm. I think I understand your setup, and it does better explain how there might be two Sentry instances, if your client is running Sentry themselves and then you try to run Sentry on top of that. But what I’m not clear about is how it would bring your app (or even your Sentry instance) down. The
hub.startSessioncall is the last thingSentry.initdoes, after everything else has already been set up. So, yes, the error would trigger with the version mismatch, but after that, everything should work normally. (I was able to send a test message from the console on https://houdinisportswear.com/sv-se, for example.)In any case, because you’re now the third person with this same problem (albeit for different reasons each), I’ve put up a PR wrapping that specific call in a check for the existence of
hub.startSession.@danieltroger, yeah I’ve been battling the same thing as mentioned above and in https://github.com/getsentry/sentry-javascript/issues/3206.
The latest update from @lobsterkatie over there (thanks!):
I’m still waiting on a new release of my presumably problematic dependency (
filestack-js), so I haven’t confirmed the@sentry/minimalversion bump actually fixes this issue (but it’s sounding like it will).I’ll let @lobsterkatie shed some more light on your scenario, though, as it sounds like you don’t have control over the version of the other Sentry instance.
Unfortunately, Proxy is not supported in IE, thus we’d need to pull a whole polyfill for that. And it’s actually one of the solutions to the ad-blockers issue that we recommend - https://docs.sentry.io/platforms/javascript/troubleshooting/#dealing-with-ad-blockers
Since the work is now in the
filestackend of things, I’m going to close this. Please let me know if problems persist after they upgrade.@lobsterkatie, that’s a good thought but not the case.
I spent some more time with this and isolated the issue to a conflicting
filestack-jsdependency. Here’s a simple sandbox that illustrates the issue. I haven’t looked into their implementation yet and am happy to reach out to them about it, but do any of you have any thoughts / recommendations?It’s worth noting this issue seems to prevent a bunch of context from making its way to Sentry as well.