-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($log): don't parse error stacks manually outside of IE/Edge #15767
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A concern about a possible BC (for tests).
LGTM otherwise.
src/ng/log.js
Outdated
// break apps. Other browsers display errors in a sensible way and some of them map stack | ||
// traces along source maps if available so it makes sense to let browsers display it | ||
// as they want. | ||
if (arg.stack && (msie || /\bEdge\//.test($window.navigator.userAgent))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, this is adding a new requirement that mocking $window
on tests (directly or indirectly) relying on $log.error()
must include navigator.userAgent
. This might break some tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be fixed by changing that into $window.navigator && $window.navigator.userAgent
. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
Also, I think it is a good idea to do this whole check once when instanciating the $log
service:
var formatStackTrace = msie || ($window.navigator && /\bEdge\//.test($window.navigator.userAgent));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR updated.
IE/Edge display errors in such a way that it requires the user to click in 4 places to see the stack trace. There is no way to feature-detect it so there's a chance of the user agent sniffing to go wrong but since it's only about logging, this shouldn't break apps. Other browsers display errors in a sensible way and some of them map stack traces along source maps if available so it makes sense to let browsers display it as they want. Fixes angular#15590
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
IE/Edge display errors in such a way that it requires the user to click in 4 places to see the stack trace. There is no way to feature-detect it so there's a chance of the user agent sniffing to go wrong but since it's only about logging, this shouldn't break apps. Other browsers display errors in a sensible way and some of them map stack traces along source maps if available so it makes sense to let browsers display it as they want. Fixes #15590 Closes #15767
IE/Edge display errors in such a way that it requires the user to click in 4 places to see the stack trace. There is no way to feature-detect it so there's a chance of the user agent sniffing to go wrong but since it's only about logging, this shouldn't break apps. Other browsers display errors in a sensible way and some of them map stack traces along source maps if available so it makes sense to let browsers display it as they want. Fixes angular#15590 Closes angular#15767
IE/Edge display errors in such a way that it requires the user to click in
4 places to see the stack trace. There is no way to feature-detect it so
there's a chance of the user agent sniffing to go wrong but since it's only
about logging, this shouldn't break apps. Other browsers display errors in
a sensible way and some of them map stack traces along source maps if available
so it makes sense to let browsers display it as they want.
Fixes #15590
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.
What is the current behavior? (You can also link to an open issue here)
Stack traces don't have source maps applied in any browser. The stack trace is formatted by Angular and printed as a string.
What is the new behavior (if this is a feature change)?
Stack traces have source maps applied in Chrome/Safari. The received error is printed as-is instead of printing a transformed stack trace.
Does this PR introduce a breaking change?
Maybe? The format of logged exceptions is not specified in the docs but there is a chance someone depends on it always being a string.
Please check if the PR fulfills these requirements
Docs have been added / updated (for bug fixes / features)Other information: