Skip to content

There are some types of exceptions that can't be caught by @sentry/nextjs #3543

Closed
@redshoga

Description

@redshoga

Package + Version

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

Version:

"@sentry/nextjs": "^6.3.6",
"next": "^10.0.8",

Description

Exceptions that do not jump to an error page, such as the following, can be correctly detected by Sentry.

import React from 'react';

const Sample: React.FC = () => {
  return (
    <button
      onClick={() => {
        throw new Error('Sentry Frontend Error! in useEffect');
      }}
    >
      Throw error
    </button>
  );
};

export default Sample;

However, Sentry will not detect exceptions that redirect to error pages, such as the following, if you only set @sentry/nextjs.

import React, { useEffect } from 'react';

const Sample: React.FC = () => {
  useEffect(() => {
    throw new Error('Sentry Frontend Error! in useEffect');
  }, []);

  return (
    <button
      onClick={() => {
        // throw new Error('Sentry Frontend Error! in useEffect');
      }}
    >
      Throw error
    </button>
  );
};

export default Sample;

Does the developer need to include code on the _error page to notify Sentry, as in the following sample?

https://github.com/vercel/next.js/blob/canary/examples/with-sentry/pages/_error.js

Metadata

Metadata

Labels

Package: nextjsIssues related to the Sentry Nextjs SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions