-
Notifications
You must be signed in to change notification settings - Fork 27.4k
No sourcemap-enabled stack trace in loadModules $injectorMinErr (at least not in Chrome) #15590
Comments
It would be nice to have better support for sourcemaps, but I am not sure how we can do this (without dropping Maybe we could provide some hooks for people to customize their error reporting (i.e. the behavior of angular.errorHandlingConfig({
objectMaxDepth: 2,
beforeError: function() {
var lastArg = arguments[arguments.length - 1];
if (lastArg instanceof Error) console.error(lastArg);
}
}); |
@motin Thanks for the report. I've been thinking about this problem in a while. In my apps I workaround it via replacing the myModule
.factory('$exceptionHandler', () => {
'ngInject';
return (...params) => {
console.error(...params);
};
}); I've been thinking about removing this whole preprocessing inside of the I've been looking at how various browsers deal with stack traces referring to files with source maps attached if and here is what I found:
In IE/Edge you have to click once to reveal the object which will show you (among other things) the beginning of the stack. You have to then click on the stack to actually get it. Not the most pleasant experience. What's worse, in the exception handler we're actually often passing an error as the first argument and the cause (a string) as the second one. In such a case under the hood we get something like If we changed that to Stopping formatting the errors would then decrease the developer experience in IE/Edge. Because of that, we've been thinking about user agent sniffing Edge (IE detection is simple; just check Error logging in Edge (
|
@csuwildcat A while ago you reached to us to see if there are any issues in Edge that affect AngularJS in particular so that the Edge team can prioritize them. This is one of those issues (see my comment above, with screenshots, to get the problem). Are you still the person-to-go wrt issues affecting major frameworks/libraries? If not, who can we contact? I opened an issue in the Edge bug tracker about the above problem: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10868717/ |
Thank you! That workaround improves usability of stack traces HEAPS, simply by finally showing the actual line of the error. Without the workaround: With the workaround: Night and day! :) |
@mgol just seeing this, apologies on the delay. I am no longer working in depth on Edge, but I can try to track down the person who handles this now if that would still help? |
@csuwildcat I opened https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10868717/ to track the issue, it's been closed as it apparently requires bigger architecture changes which have a uservoice entry at https://wpdev.uservoice.com/forums/257854-microsoft-edge-developer/suggestions/6225641-call-stacks-for-messages. We'd appreciate if this change was prioritized in some way but I'm not sure how feasible it is for you in the nearby future. |
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
PR: #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
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
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
Do you want to request a feature or report a bug?
Bug
Current behavior + steps to reproduce
What is the expected behavior?
On step 4, the stack trace should reference the actual source files, so that it is easy to understand where the problem lies in the source code, namely config.js:
What is the motivation / use case for changing the behavior?
Easier debugging of module inclusion, especially important when migrating to webpack or other bundler that requires sourcemaps to even have a change debugging in the development-environment.
Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
Angular 1.6.1 (latest stable)
Chrome 55
Mac OSX El Capitan
Have not tested with latest snapshot.
Other information (e.g. stacktraces, related issues, suggestions how to fix)
A workaround is to replace the following line in angular.js:
throw $injectorMinErr('modulerr', 'Failed to instantiate module {0} due to:\n{1}',
module, e.stack || e.message || e);
with:
throw e;
This yields an understandable stacktrace in the console (shown above).
Note, according to https://bugs.chromium.org/p/chromium/issues/detail?id=376409 "there is no way to fix it for Error.stack property because this property is generated by V8 which know nothing about source map". Despite this, e.stack is preferred as the ErrorConstructor argument over e.
This is evident when running
console.log(e, e.stack);
just before the error is throw. First an error with a sourcemap-enabled stacktrace is displayed in the console, then a stacktrace without sourcemaps.
However, simply replacing "e.stack || e.message || e" with "e" leads to a stack trace with sourcemaps enable but without config.js mentioned:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
{}
http://errors.angularjs.org/1.6.1/$injector/modulerr?p0=app&p1=%7B%7D
at angular.js:68
at angular.js:4764
at forEach (angular.js:357)
at loadModules (angular.js:4720)
at createInjector (angular.js:4642)
at doBootstrap (angular.js:1838)
at bootstrap (angular.js:1859)
The text was updated successfully, but these errors were encountered: