You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If _parseJson (and internal JSON.parse) throws an error, it will not be passed to reject, so outer getMappedLocation (and StackTrace.fromError from stacktrace-js) will never resolve/reject.
varsourceMapConsumerPromise=newPromise(function(resolve,reject){returnthis._get(sourceMappingURL).then(function(sourceMapSource){if(typeofsourceMapSource==='string'){// throws from here vvvsourceMapSource=_parseJson(sourceMapSource.replace(/^\)\]\}'/,''));}if(typeofsourceMapSource.sourceRoot==='undefined'){sourceMapSource.sourceRoot=defaultSourceRoot;}resolve(newSourceMap.SourceMapConsumer(sourceMapSource));},reject);//<- not caught in here}.bind(this));
Expected Behavior
Invalid source map errors can be caught by StackTrace.fromError(...).catch an others.
Current Behavior
Error becomes unhandled rejection and can not be caught.
Steps to Reproduce
Try to getMappedLocation for source map with some invalid JSON content (for example <html).
Context
I'm trying to catch every possible error with addEventListener('error' and addEventListener('unhandledrejection', enhance stack trace and send it to server. Currently, server is configured to respond with index.html for non-exiting paths. If .map file is missing for some reason, stacktrace-js receives some HTML instead of JSON, fails and no error is sent at all.
What is worse, this unhandled rejection is caught by 'unhandledrejection' handler and passed it to StackTrace.fromError again, which results in an infinite loop.
Your Environment
stacktrace.js version: 2.0.2
Browser Name and version: Chromium 80.0.3987.116
Operating System and version: Arch Linux (desktop)
If
_parseJson
(and internalJSON.parse
) throws an error, it will not be passed toreject
, so outergetMappedLocation
(andStackTrace.fromError
fromstacktrace-js
) will never resolve/reject.https://github.com/stacktracejs/stacktrace-gps/blob/v3.0.4/stacktrace-gps.js#L240-L251
Expected Behavior
Invalid source map errors can be caught by
StackTrace.fromError(...).catch
an others.Current Behavior
Error becomes unhandled rejection and can not be caught.
Steps to Reproduce
Try to
getMappedLocation
for source map with some invalid JSON content (for example<html
).Context
I'm trying to catch every possible error with
addEventListener('error'
andaddEventListener('unhandledrejection'
, enhance stack trace and send it to server. Currently, server is configured to respond withindex.html
for non-exiting paths. If.map
file is missing for some reason,stacktrace-js
receives some HTML instead of JSON, fails and no error is sent at all.What is worse, this unhandled rejection is caught by
'unhandledrejection'
handler and passed it toStackTrace.fromError
again, which results in an infinite loop.Your Environment
Possible Solution
The text was updated successfully, but these errors were encountered: