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

Errors not thrown #88

Closed
codepunkt opened this issue Mar 30, 2015 · 15 comments
Closed

Errors not thrown #88

codepunkt opened this issue Mar 30, 2015 · 15 comments

Comments

@codepunkt
Copy link

Chrome 41 throws uncatched errors using native window.Promise:

new window.Promise(function(res, rej) {
  throw new Error('window.Promise');
});

The only way i can achieve this behavior using es6-promise is by re-throwing in a setTimeout in catch:

var Promise = require('es6-promise');

new Promise(function(res, rej) {
  throw new Error('es6-promise');
}).catch(function(err) {
  setTimeout(function() {
    throw err;
  }, 0);
});

This is not developer-friendly at all.
While i've read #70, #71 and especially #40 i don't get how this is specced behavior. Can't find anything in the current ES6 draft on this.

Maybe someone can shed a little light.

@stefanpenner
Copy link
Owner

Chrome actually doesn't throw them, rather an unspeced log. I agree it would be good to add that back to this project.

@allanhortle
Copy link

Bump. This is strange behaviour.

@jakearchibald
Copy link
Collaborator

Throwing via setTimeout isn't the right solution here - as Stefan points
out Chrome's doing a simple log, whereas a throw will bubble up to
window.onerror.

On Tue, 31 Mar 2015 00:49 Allan Hortle [email protected] wrote:

Bump. This is strange behaviour.


Reply to this email directly or view it on GitHub
#88 (comment)
.

@stefanpenner
Copy link
Owner

I've been saturated with other OSS responsibilities, but I will circle around and push this forward :)

@juandopazo
Copy link

@stefanpenner I can help.

So one way to do this would be:

  1. On Reject, if there are no error handlers do promise.__errorLogTimeout = setTimeout(() => console.error(error), 5000)
  2. On then/catch, clearTimeout(promise.__errorLogTimeout).

@stefanpenner
Copy link
Owner

So one way to do this would be:

On Reject, if there are no error handlers do promise.__errorLogTimeout = setTimeout(() => console.error(error), 5000)
On then/catch, clearTimeout(promise.__errorLogTimeout).

awesome, but its has a few more requirements.

I have implemented something (quick and dirty) that closely mimics (but doesn't quite match) the expected heuristics. in RSVP (the parent project) https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/promise.js#L176-L182

It would actually be easier to implement it more heuristically correct in this project, as the async isn't pluggable as it is in ember.

So basically, Errors are logged only if not handled before the next macroTask. So their is a concise window where errors need to be handled, and where errors need to be logged.

@juandopazo
Copy link

Don't you think "the next macrotask" is too soon?

@stefanpenner
Copy link
Owner

Don't you think "the next macrotask" is too soon?

i don't believe so, we really need the browsers to give us access to their new promise pane....

@stefanpenner
Copy link
Owner

@domenic share your thoughts?

@domenic
Copy link
Contributor

domenic commented Apr 2, 2015

I'd just log on next macrotask and log again when it's caught. Chrome still is implementing the last part.

@stefanpenner
Copy link
Owner

duplicate: #70

@stefanpenner
Copy link
Owner

@domenic

Chrome still is implementing the last part.

the last part being, giving userland promises access to the new promise pane?

@domenic
Copy link
Contributor

domenic commented Apr 4, 2015

No, greying out the log when the rejection gets handled.

@stefanpenner
Copy link
Owner

@domenic lame :P

@ysmood
Copy link

ysmood commented Jun 25, 2015

Event Chrome and Bluebird is not good enough for me. I wrote mine, see the comparison: https://github.com/ysmood/yaku/blob/master/docs/debugHelperComparison.md

For more details: https://github.com/ysmood/yaku

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

7 participants