-
Notifications
You must be signed in to change notification settings - Fork 27.3k
$http suppressing syntax errors #15887
Description
I'm submitting a ...
- bug report
- feature request
- other (Please do not submit support requests here (see above))
Current behavior:
If a javascript syntax error occurs in a promise.then chain, the promise is now rejected where the error is send as response to the next chain's reject function. This causes our main javascript errorHandler to not trigger, nor to have the error logged in the console. Whilst the code does stop working.
Expected / new behavior:
It used to work in angular 1.5.5, it no longer does in 1.6.2 -> 1.6.4. Syntax error's / programming errors should not just be caught in a promise and then reject the promise. They should always be fired as the syntax error they are.
Minimal reproduction of the problem with instructions:
angular 1.5.5 working:
https://plnkr.co/edit/fi32lCTkH7U8zgYQQWLN
angular 1.6.3 no longer working (1.6.4 isn't CDN available yet)
https://plnkr.co/edit/zoYtfbCfElr2MKmMP7RG
Setup angular version 1.6.4, start a $http call to an API with a JSON response, use the following successFunction
function processResponse( response ) {
response.nonExistingVar.subVariable = 'test';
}
It should result in : Uncaught TypeError: Cannot set property 'subVariable' of undefined, instead your code is silent.
Add a second .then with the following reject function (or a catch);
function errorFunction( response ) {
console.log( response );
}
Angular version: 1.6.4
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
Alteast in Chrome 57.0.2987.98 (64-bit), but i think in all browsers
Anything else:
It seems to relate to this issue: #15855