question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Internal Sentry Error: r._mergeOptions is not a function

See original GitHub issue

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.15.5

Description

This error is related to another issue: https://github.com/getsentry/sentry-javascript/issues/2541

As per the Advance Usage docs, I am trying to manage several instances of Sentry. I am developing a widget and would like to use Sentry without it conflicting with the host page.

Based on the documentation and suggestions from this thread, I am achieving this using a new Hub instance, and calling the run method inside the widget.

My (simplified) code looks like:

const client = new BrowserClient({
  dsn: process.env.SENTRY_DSN,
  integrations: [
    new Sentry.Integrations.InboundFilters(),
    new Sentry.Integrations.UserAgent(),
    new Sentry.Integrations.Breadcrumbs()
  ]
});

const hub = new Hub(client);

// Based on https://github.com/getsentry/sentry-javascript/issues/2541
hub.bindClient(client);
...

hub.run((currentHub) => {
    currentHub.captureException(error);
});

For host pages without Sentry, everything works well. However, on host pages where Sentry is already being used, internal Sentry exceptions are being thrown from each Sentry package. This line breaks with the message r._mergeOptions is not a function.

This error will appear in both Sentry projects. It appears that somehow they might be breaking each other, and logging the exception. Integrations do not work in these exceptions, I assume because it’s the integrations that are breaking.

There are still other exceptions that are logged correctly by both projects, so it’s unclear when or how this situation arises. It’s also unclear if this error is gobbling other exceptions.

This is a major use-case for our organization. Hoping for a fix or suggestion so that we can resolve quickly (for now we need to turn Sentry off).

Links to the issue:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:9
  • Comments:29 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
nmackeycommented, Dec 22, 2021

I’m running into this error with my app. My app is a 3rd party app loaded by pages that I don’t control so my guess is that some of these pages are loading Sentry as well. I am already using a version that includes @kamilogorek fix above however most of my sentry error reports seem to be this problem related to _mergeOptions. Is there a recommendation on how to deal with this?

Couple of follow up questions: When this error happens does this prevent sentry from reporting additional errors? Should I just filter out this error using the Inbound Filters in Sentry?

3reactions
nicklaw5commented, Sep 20, 2020

I managed to resolve my issue above. I ended up having multiple calls to Sentry.init(...) in the same page load. After I removed the duplicate call, everything worked as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting for JavaScript - Sentry Documentation
By default, Sentry does not capture errors when a resource (like an image or a css file) fails to load. If you would...
Read more >
@sentry/node | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Saved diff 6JbpEuJa - Diffchecker
isSentryError(t,e)?(X.warn("Event dropped due to being internal Sentry Error. ... r[t].apply(r,l(e));throw new Error("No hub defined or "+t+" was not found ...
Read more >
Newest 'sentry' Questions - Stack Overflow
I'm working on a React application inside my NX Workspace. ... Error n.getTransport is not a function (@sentry) ... Harish Kumar R B's...
Read more >
Event Type Definitions - Sentry Developer Documentation
This is a best-effort guess at whether the exception was handled by user code or not. For example: Exceptions leading to a 500...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found