Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
'undefined is not a function' when promise function not defined #11330
Using 1.4.0-beta.5, the following stack trace seems to be the result of an error() function not being defined during promise rejection. The rejection still bubbles up, however the "undefined is not a function" is logged in the console.
The problem is that the error is not nice at all and since it's thrown usually asynchronously with respect to where the callback was registered, it's really hard to debug.
Could we just silently ignore, if the callback is not a function? Would this break Promises A+ spec?
a little bit more context: https://twitter.com/olore/status/577277479506837504
OK, so this is hard to debug but it is a JS development error not a failure in Angular. Wherever there is code that takes a callback, you have to have defined the callback before you pass it to the code.
Silently ignoring if the callback is not a function will make this even more difficult to debug! There won't even be an error but the error callback will silently not be called if the HTTP request errors.
I think we could throw an error if you call
added a commit
Mar 16, 2015
referenced this issue
Mar 16, 2015
The only reason the promise spec allows us to ignore params is because they are all optional but I am pretty sure that passing no parameters is always an error. In the case of