Skip to content

[React ErrorBoundary] Cannot create property 'cause' on string #6167

Closed
@voliva

Description

@voliva

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/react

SDK Version

7.18.0

Framework Version

18.2.0

Link to Sentry event

No response

Steps to Reproduce

  1. Create a react component that throws an error which is not from an Error constructor (such as throwing a string)
  2. Wrap this component with an ErrorBoundary from sentry
  3. Run it

Example codesandbox: https://codesandbox.io/s/infallible-sun-urw7yh?file=/src/App.js

Expected Result

The error should get captured and sent to Sentry as a Non-Error exception

Actual Result

The ErrorBoundary causes another error when it tries to set the property cause onto the original one. Because it's not an Error object, but in this case a primitive type, then it throws that other error.

This exception then bubbles further up to the next ErrorBoundary, dismounting other components that shouldn't be dismounted.

Metadata

Metadata

Assignees

Labels

Package: reactIssues related to the Sentry React SDK

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions