fix: Attempt to provide some information for <unlabeled event> #1397
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This one was very tricky to debug and fix. Some details and reasoning behind the fix.
First, there are 3 ways to trigger this issue, so let's go one by one:
Before
captureException('')
There's no type and no message, as when a string is passed, it'll fallback to
captureException
. The thing why it's special is that we default tostracktrace: true
and there's synthetic stack trace created bynew Error('')
which should help a user to debug the issue.captureMessage('')
No type, no message, and no stack trace, as we default to
false
when usingcaptureMessage
directly :(throw ''
No type, no message, no stack trace, and parse error on top of that :(
After
captureException('')
No changes.
captureMessage('')
We have a stack trace now \o/
throw ''
Overriden type. More reasonable message. No processing error and file, line and column of the main call \o/
FAQ
Why it only affects
''
?Because
null
andundefined
coerce to their string representation and are valid labelsWhy can we not fix it using synthetic stack traces in TraceKit?
Because by the time
throw ''
reaches global error handler, you cannotnew Error('')
it anymore. It has no data that can be fed to the constructor.Are there other ways around if once I find the culprit?
Yes, you can use
Ref: #1271