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

Unhandled rejection detection #20

Closed
benjamingr opened this issue May 19, 2015 · 12 comments
Closed

Unhandled rejection detection #20

benjamingr opened this issue May 19, 2015 · 12 comments

Comments

@benjamingr
Copy link

If you'd like, implementing this API would be really awesome, Bluebird When and native promises on the server do this:

https://gist.github.com/benjamingr/0237932cee84712951a2

Cheers

@calvinmetcalf
Copy link
Owner

I have some very mixed feelings on this, on one hand it's an extremely useful feature on the other in's a non standard api so so this would no longer be a drop in replacement for native promises which can cause problems (see pouchdb/pouchdb#3839)

@benjamingr
Copy link
Author

@calvinmetcalf it is a standard API in that everyone implements it, in fact native promises already do it in io.js and NodeJS accepted it but since the merger was declared they're just waiting for io.js to merge with node over the io.js codebase.

This is mostly useful in order to be compatible with native promises. nodejs/node#256

Documented here: https://iojs.org/api/process.html#process_event_unhandledrejection btw

Note that this mostly affects server-side usage.

@calvinmetcalf
Copy link
Owner

yeah it's browserify usage I'm thinking of that could be affected

@benjamingr
Copy link
Author

Hmm how so? The code checks if process and process.emit are there and only emits the events then - it might be really nice to emit window events like bluebird does but that's not required of the spec.

You can see how I implemented this in Q here: kriskowal/q@1c38507

@calvinmetcalf
Copy link
Owner

if somebody does something like var Promise = global.Promise || require('lie'); you would or would not have events depending on your browser

@benjamingr
Copy link
Author

@calvinmetcalf if someone does var Promise = global.Promise || require("lie"); you would not have events anyway since there is no process object.

These events already happen on the serverside in which case if a library is using lie instead of native promises they would not get errors. In fact you'd only get native errors if you do:

var p = Promise.reject(new Error(...)); // fires an event if no `catch` is attached within a microtask flush
var p = lie.reject(new Error(...)); // no process event, unlike native promises, Q, bluebird etc etc.

@calvinmetcalf
Copy link
Owner

let me look into how I can impliment it to work server side without increasing the client side code footprint unnecessarily

@benjamingr
Copy link
Author

I was going to point out you can use a tool like envify and then use the fact minifiers strip dead code but it seems like you've figured something out already :) Thanks.

@calvinmetcalf
Copy link
Owner

Yeah the env seemed like a bit of a hack plus down stream packages could have used conflicting env stuff

@benjamingr
Copy link
Author

Yes, the approach you took does sound better. Let me know if you need any help pushing this forward and thanks for doing this :)

@calvinmetcalf
Copy link
Owner

done in 2.9.0

@benjamingr
Copy link
Author

Awesome, thanks a ton!

On Wed, May 27, 2015 at 2:53 PM, Calvin Metcalf [email protected]
wrote:

done in 2.9.0


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

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