Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback or errorback exception disappears #82

Closed
dizzib opened this issue Apr 23, 2012 · 5 comments
Closed

Callback or errorback exception disappears #82

dizzib opened this issue Apr 23, 2012 · 5 comments
Assignees
Milestone

Comments

@dizzib
Copy link

dizzib commented Apr 23, 2012

An exception thrown in a callback or errorback seems to get swallowed.

Reproducable in hello-wire.js by amending index.html line 52...

function ok() { throw new Error('bar'); }
function fail() { throw new Error('bop'); }
require(['wire!hello-wired-spec']).then(ok, fail);

On run, the error 'bar' simply disappears. Likewise error 'bop' disappears when the errorback runs.

@unscriptable
Copy link
Member

curl's promise-like API is really just a simplistic promises implementation and isn't Promises/A compliant, so a failure in the success callback ("ok" function in your snippet) won't trigger the failure callback. Hm... this seems like a useful feature and should be easy to implement. I'll take a closer look.

FWIW, I'm not sure it makes much sense to try to do something when an exception happens in the failure callback. :)

-- J

@ghost ghost assigned unscriptable Apr 23, 2012
@dizzib
Copy link
Author

dizzib commented Apr 23, 2012

Hmm, I'd have thought any errors occuring in the callback or errorback should be allowed to continue on their way without being handled by curl. Or am I missing something ?

@unscriptable
Copy link
Member

"continue on their way" to where? It looks like they're declared in the global scope. If so, the only thing that could catch them would be window.onerror (in browsers where it's supported).

@dizzib
Copy link
Author

dizzib commented Apr 23, 2012

Sorry, yes I'd have global window.onerror handler which would handle them.

I'm encountering a scenario where an error occurs but my app isn't aware of it and continues to display a 'loading please wait...' message indefinitely (also see #81). One possible workaround is that I detect that my app hasn't loaded after, say 30 seconds, then display an error.

@unscriptable
Copy link
Member

I opened a ticket on wire.js (cujojs/wire#32). I'm closing this issue, but feel free to open it if there's more to chat about. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants