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

Parse Promise Then Handler Doesn't Crash With Error #615

Closed
btate opened this issue Feb 24, 2016 · 6 comments
Closed

Parse Promise Then Handler Doesn't Crash With Error #615

btate opened this issue Feb 24, 2016 · 6 comments

Comments

@btate
Copy link

btate commented Feb 24, 2016

When I experience a javascript error in my promise then handler my requests just hang. No error shows up in the console and the code doesn't return.

In a promise.then() handler just add this line.

notarealvar.notarealthing();

The request just hangs. If you wrap it in a try catch you can see an error.

@btate btate changed the title Parse Hooks Don't Crash With Error Parse Cloud Code Methods Don't Crash With Error Feb 24, 2016
@btate btate changed the title Parse Cloud Code Methods Don't Crash With Error Parse Promise Then Handler Doesn't Crash With Error Feb 24, 2016
@nlutsenko
Copy link
Contributor

cc @andrewimm

@andrewimm
Copy link
Contributor

This is part of the Promises/A+ spec. Thrown exceptions within the execution of a promise are caught by the promise, and passed to the next error callback.

If you want to catch the exceptions that have occurred up until a point, just provide an error callback to any .then() call. Or, if you want to avoid Promises/A+ compatibility, you can always disable it with Parse.Promise.disableAPlusCompliant()

@btate
Copy link
Author

btate commented Feb 24, 2016

There is an error callback that just calls response.error(error). But it was never called so the cloud code method never responded.

@andrewimm
Copy link
Contributor

Code sample?

Keep in mind, if you do

someTask().then( onSuccess, onError )

the error handler will catch exceptions from someTask, but will not catch exceptions from onSuccess

@btate
Copy link
Author

btate commented Feb 24, 2016

Gotcha. Yeah it's code in the onSuccess that's failing silently.

@andrewimm
Copy link
Contributor

I tend to tack on a final .fail((e) => ... ) callback to the entire chain to handle the errors in there (fail(x) is an alias for then(null, x))

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

3 participants