Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-Error exception captured with keys: currentTarget, isTrusted, target, type #7941

Closed
3 tasks done
SunStupic opened this issue Apr 24, 2023 · 18 comments
Closed
3 tasks done
Labels
Package: browser Issues related to the Sentry Browser SDK Stale Type: Bug

Comments

@SunStupic
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

Sentry Browser CDN bundle

SDK Version

latest

Framework Version

[email protected]

Link to Sentry event

https://workstream-is.sentry.io/issues/4086742434/?project=6108198&referrer=jira_integration

SDK Setup


      Sentry.init({
        release: "#{env.SENTRY_RELEASE}",
      });

Steps to Reproduce

No we cannot reproduce it.

Expected Result

No event object should be thrown as error

Actual Result

Weird empty event object is thrown

@SunStupic
Copy link
Author

SunStupic commented Apr 24, 2023

This is similar to the sibling task except

  1. it's an exception not an promis rejection
  2. The event object is slightly different

Although the doc says I should tell where does this structure come from, but I cannot really tell

{currentTarget: [object Null], isTrusted: True, target: [object Window], type: error}

@Lms24
Copy link
Member

Lms24 commented Apr 25, 2023

Hi @SunStupic thanks for writing in!

Unfortunately, I can't really tell you either where this error is coming from. You mentioned #6199 already and I also think that this is related. Maybe it is also some script that failed to load. Just that it errored instead of throwing a promise rejection. It's very hard for us to diagnose these issues without a reproduction. Happy to look into it if there's a way to reproduce this.

If you you don't want to see this issue, I suggest you use beforeSend to filter it out:

Sentry.init({
  dsn: 'your_dsn',
  // ...
  beforeSend: (event) => {
    const exception = event.exception?.values && event.exception?.values[0]
    if (exception?.value === 'Non-Error exception captured with keys: currentTarget, isTrusted, target, type') {
      return null;
    }
    return event;
  } 
})

@AbhiPrasad
Copy link
Member

What's interesting is we've got a spike of these happening as well on the sentry frontend. From looking at Replays with this error, it seems to not impacting the user experience, so it's probably something we can safely ignore.

@harryfear
Copy link

This seems to overlap with #2546 ?

We've had a spike in these occurrences also over the last 2 weeks across various web apps, inc. those with no codebase changes whatsoever.

@AbhiPrasad
Copy link
Member

Not sure what is going on here, especially since it's happening in all browsers.

Basically this occurs because something is running throw event in an event listener, and because this is not being an error thrown we can't get a stacktrace at all.

Perhaps we should just filter these server side tbh.

@msobiecki
Copy link

Hey. ;) I was able to debug when this problem occurs. In a situation where "ErrorEvent: ResizeObserver loop limit exceeded" occurs, the event in method "beforeSend" appears as "ErrorEvent: Non-Error exception captured with keys: currentTarget, isTrusted, target, type". This may lead to a fix for the problem.

Version: 7.51.2
image

Interestingly, it worked fine in older versions:

Version: 5.30.0
image

@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@filips123
Copy link
Contributor

I have a similar error on my Vue+Vuetify website:

Non-Error promise rejection captured with keys: currentTarget, isTrusted, target, type
https://gimvicurnik.sentry.io/issues/4214962671

__serialized__ = {
    currentTarget: [object Window],
    isTrusted: False,
    target: [object Window],
    type: unhandledrejection
}

It happened twice in the past week on Firefox 113, but I cannot reproduce it myself and I don't know why it happens.

I use captureException a few times though, but I think they are only capturing exceptions. Once in a custom router instrumentation (which is based on default Vue Router instrumentation), and a few times when handling HTTP errors (there is a custom fetchHandle that throws an error on HTTP errors).

Will this error be filtered on Sentry servers in the future? Or, is it possible to get more useful details about such errors (stack trace, what those [object Window]s are, etc.) without too much manual SDK configuration?

@SunStupic
Copy link
Author

Yes, my investigation ended at "ErrorEvent: ResizeObserver loop limit exceeded" as well. It's not affecting user experience at all. So this is not an issue actually.

mydea added a commit that referenced this issue Jun 23, 2023
This PR adjusts the exception name generation for non-error objects in
the browser SDK.

ref #7941
@mydea
Copy link
Member

mydea commented Jun 23, 2023

FYI, we have just merged a PR that, while not fully addressing the issues outlined here, should at least help a bit with clearing this up: #8374

With this PR, the error messages should at least be clearer. When an Event is captured by captureException, it will better show what kind of event it is, and if it is an ErrorEvent, it will also show the error message.

What this does not address is why sometimes there is no stack track. TBH I am not quite sure why this is happening, as for non-error exception we should be using a syntethic exception to get some stack trace at least. So this remains open for investigation 🤔

@dav-q
Copy link

dav-q commented Sep 1, 2023

I encountered an error similar to this
Error reported by Sentry: Non-Error promise rejection captured with keys: message, status, key

  • message, status, key are the keys of an object returned by an API service call.

Environment

I'm using @sentry/reactv 7.66.0 ,react v18.2.0, react-redux 8.0.5, and fetch for handling requests.

Behavior

  • The React component calls an asynchronous action from Redux.
    await dispatch(action()).unwrap();

  • The action function is defined as follows:

export const action = createAsyncThunk( 'test/action', async (params, thunkAPI) => {
    const { data, statusKey, success } = await APICall(params);
    if (success) return { ...data, statusKey };
    return thunkAPI.rejectWithValue({ ...data, statusKey });
  }
);
  • The APICall function is defined as follows:
const APICall = async (params) => {
    const response = await fetch(`url`);
    if (!response.ok) throw new Error('Error');    
    const data = await response.json();
    return data;
};
  • When !response.ok, the error is reported to Sentry for some reason.
  • When !response.ok and the action await dispatch(action()).unwrap() is wrapped in a try{}catch block, no error is reported.
  • When !response.ok and the action is not awaited, dispatch(action()), no error is reported.

FYI, this doesn't affect users at all but causes uncertainty due to so many reported errors.

Maybe this can help someone

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 Sep 1, 2023
@mydea
Copy link
Member

mydea commented Sep 4, 2023

@dav-q do you use Sentry SaaS (sentry.io)? If so, could you share a link to such a captured event? I don't really see how/when this kind of message would still be generated in the source code in a current version, but maybe I am missing something somewhere...!

@getsantry getsantry bot removed the status in GitHub Issues with 👀 Sep 4, 2023
@getsantry getsantry bot moved this to Waiting for: Community in GitHub Issues with 👀 Oct 3, 2023
@getsantry
Copy link

getsantry bot commented Oct 25, 2023

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@davidszotten
Copy link

@mydea i'm also tracking the same symptom and we're on sentry saas. what's the best way for me to privately share an event link?

@mydea
Copy link
Member

mydea commented Nov 15, 2023

@mydea i'm also tracking the same symptom and we're on sentry saas. what's the best way for me to privately share an event link?

I sent you an email (got your email from your website, hope it's the correct one)!

@mydea
Copy link
Member

mydea commented Nov 16, 2023

Just shortly following up here as well, @davidszotten in your case you're running an old version of the SDK (6.x), we shipped this change in v 7.57.0!

@davidszotten
Copy link

thanks for pointing me in the right direction @mydea .

sadly bumping the sdk just seems to have replaced that error with

Event ErrorEvent captured as exception with message Script error.

@mydea
Copy link
Member

mydea commented Nov 17, 2023

@davidszotten yeah, that can still happen in the latest version of the SDK. Basically, this is an error where we just don't seem to have more info than message: "Script error.". You can filter this out via inbound filters:

Sentry.init({
  ignoreErrors: ['Event `ErrorEvent` captured as exception with message `Script error.`']
});

Does that work for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: browser Issues related to the Sentry Browser SDK Stale Type: Bug
Projects
Archived in project
Development

No branches or pull requests

10 participants