You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide a link to the affected event from your Sentry account
Package + Version
@sentry/browser
Version:
6.2.0
Description
We've changed our sentry browser client from using the global instance to use a separate instance with 'BrowserClientand Hub` and integrations don't seem to be called anymore, since the Breadcrumbs, userAgent, etc data is not being sent as before. We use the default integrations. This is our init code:
import*asSentryfrom"@sentry/browser";constclient=newSentry.BrowserClient({dsn: "%%dsn%%",release: '%%library_version%%',dist: '%%build_number%%',environment: process.env.NODE_ENV,integrations: [...Sentry.defaultIntegrations]});consthub=newSentry.Hub(client);console.log(hub.getClient()._integrations)// We can see integration instances
Our previous init was the following and integrations were working with no problem:
import*asSentryfrom"@sentry/browser";constclient=newSentry.BrowserClient({dsn: "%%dsn%%",release: '%%library_version%%',dist: '%%build_number%%',environment: process.env.NODE_ENV,integrations: [...Sentry.defaultIntegrations]});consthub=newSentry.Hub(client);// This call is missing.Sentry.makeMain(hub);
Unfortunately, right now you need to register the Hub so that integrations can detect it.
We are reworking integrations in the next major release so they will not rely on the globally registered hub.
Reacted by Dmitriy Petrov, GorgeChan, whatwg6 and Raphael Brandão
@kamilogorek, how can we currently prevent this call makeMain if we have multiple instances of Sentry running in the same application? Similar to this issue: #2783
Thanks
@kamilogorek, how can we currently prevent this call makeMain if we have multiple instances of Sentry running in the same application? Similar to this issue: #2783
There's no way to make integrations work for multiple clients currently, sorry.
@kamilogorek What is the current timeframe for release of v7?
@BeInLife Unfortunately using Sentry.makeMain(hub) replaces the old hub... this means that only one hub / client can be active on a single page at any given time... Not sure if this has been resolved yet in v7+ but in earlier versions this was simply not possible...
@BeInLife Unfortunately using Sentry.makeMain(hub) replaces the old hub... this means that only one hub / client can be active on a single page at any given time... Not sure if this has been resolved yet in v7+ but in earlier versions this was simply not possible...
That's correct, but that's the only way to work if you have multiple micro frontends on the same page. U need to set the main one and handle errors manually for others.
An example repo is linked with this discussion. It also helps us if you anyone facing challenges with MFEs could post on that discussion so we can collect more information
Debug integration is catching errors correctly, but it never reaches beforeSend stage (which is required before sending to Sentry), even if the hub is set to main one. So this means that majority of events aren't logged in Sentry.
What works and lands in Sentry? CaptureConsole integration.
What doesn't work and doesn't reach beforeSend stage? TryCatch integration, GlobalHandler integrations (major ones)
Activity
yyoyo commentedon Mar 8, 2021
+1
kamilogorek commentedon Mar 8, 2021
Unfortunately, right now you need to register the Hub so that integrations can detect it.
We are reworking integrations in the next major release so they will not rely on the globally registered hub.
fizz3r commentedon Mar 8, 2021
@kamilogorek, how can we currently prevent this call
makeMainif we have multiple instances of Sentry running in the same application? Similar to this issue: #2783Thanks
kamilogorek commentedon Mar 16, 2021
There's no way to make integrations work for multiple clients currently, sorry.
Q2 21', I don't have any more specific date yet.
BeInLife commentedon Dec 10, 2021
@kamilogorek Any updates for this?
What will be the behaviour if app with
mainHubwill be unmounted?yyoyo commentedon Jan 24, 2022
Hi.
any news on this ?
thanks,
BeInLife commentedon Jan 24, 2022
@yyoyo I can share my solution with you later on
Seems like it works so far
yyoyo commentedon Jan 25, 2022
Yes Please !
1 remaining item
Macavity commentedon Feb 18, 2022
@BeInLife If you have any sort of solution, can you maybe share it? ❤️
BeInLife commentedon Feb 18, 2022
Yea, will do later tonight
Forgot about it 🙄
PaulKujawa commentedon Mar 11, 2022
@BeInLife when you find time any solution would be highly appreciated!
BeInLife commentedon Mar 11, 2022
And when your app is unmounting, call
@PaulKujawa @Macavity @yyoyo
Sorry for delay
jbarker47 commentedon Jul 12, 2022
@BeInLife Unfortunately using
Sentry.makeMain(hub)replaces the old hub... this means that only one hub / client can be active on a single page at any given time... Not sure if this has been resolved yet in v7+ but in earlier versions this was simply not possible...BeInLife commentedon Jul 12, 2022
That's correct, but that's the only way to work if you have multiple micro frontends on the same page. U need to set the main one and handle errors manually for others.
giladv commentedon Oct 5, 2022
Hey,
Any news regarding this issue?
Our company has moved to a micro FE architecture and this limitation means we cannot work with sentry anymore.
smeubank commentedon Dec 30, 2022
#5217
An example repo is linked with this discussion. It also helps us if you anyone facing challenges with MFEs could post on that discussion so we can collect more information
adriandmitroca commentedon Jan 24, 2023
I've been doing some testing with this.
Debugintegration is catching errors correctly, but it never reachesbeforeSendstage (which is required before sending to Sentry), even if the hub is set to main one. So this means that majority of events aren't logged in Sentry.What works and lands in Sentry?
CaptureConsoleintegration.What doesn't work and doesn't reach beforeSend stage?
TryCatchintegration,GlobalHandlerintegrations (major ones)mydea commentedon Jun 18, 2024
We have documented this better now here: https://docs.sentry.io/platforms/javascript/best-practices/multiple-sentry-instances/ - it should work based on these docs.