-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Consider exposing promise unhandled rejection hook #8997
Comments
Anyone? |
Would you at least consider backporting this from io.js when it lands there? |
@trevnorris since you're assigned - updating you that the io.js PR was merged here: nodejs/node#758 It would be really awesome if someone could backport it into Node so node users won't have suppressed errors hint hint :) |
/cc @tjfontaine @cjihrig Thoughts on porting the patch? |
I'm +1 on it. |
Ditto. |
Nice, thanks. @tjfontaine ? |
@misterdjules how can I push this? Who would be willing to do the work on this? It shouldn't be a lot of work and the benefit for developers is huge IMO. |
Thank you very much @benjamingr for writing this proposal! I'm not familiar with promises, so I'm not in the best position to have an educated opinion, let alone to make a decision. After reading the proposal and the implementation in iojs, I have a few questions:
Since the proposal adds new APIs, the required changes would need to be merged into the master branch. It seems that the current version of V8 in this branch is missing the When and If we decide to integrate these changes, my suggestion would then be to, in this order:
How does that sound? Adding this issue to the 0.13.1 milestone so that we can track it properly. |
Hi @misterdjules - thanks for the detailed response.
These hooks might be seen as a debugging/tracing tool or they might be seen as part of the business logic of the server. I think they should be wherever
I'm afraid that realistically a decision will likely not happen for a while because it's a highly opinionated choice. The good news is that integrating these hooks into node will not require any default behaviour. These hooks are the minimal thing required in order to make promises supported in node - personally I find these hooks immensely useful even without the default action. Default behavior is something that can be worked out later. I don't think that making opinionated choices on how people write their code is the node way anyway :)
Not sure, but the internal v8 hooks were introduced in What are the next logical steps in order to move this forward? Who would be a good person to choose the relevant v8 version to upgrade to in 0.13.x? |
@benjamingr Thank you for your response too! I've read a bit more about promises but I'm still far from getting close to be familiar with them, so like I said before I won't be able to have an educated opinion until then. I think @trevnorris, @bnoordhuis and @indutny would have a better suggestion for which version of V8 we'd like to upgrade to in master, but I would think that the latest stable release could be a good candidate. According to https://omahaproxy.appspot.com, that would be version 41.0.2272.89. We could start by upgrading to that version, which would probably have its fair share of challenges (IIRC recent V8 versions require C++11 features, among other things). As far as I know, most of the team is focused on getting v0.10.37 and v0.12.1 out, so I don't know when we'll get some time to do that. If you're interested, your help would be more than welcome. Once that is done we'll be in a better position to consider (and test) whether we want to integrate nodejs/node#758. |
@misterdjules any idea on when a V8 that supports this will be upgraded to? Any updates? |
@benjamingr We are still focused on stabilizing v0.12, and haven't had the time to work on upgrading V8 to a newer version on master. Any help on that front would be very much appreciated. |
I'm eagerly waiting for this to happen :) |
@dmail that's great but it's not going to happen in the 0.12 lifespan since the v8 being used is too old, I doubt joyent would agree to hack v8 or use non-native promises. |
@benjamingr Thus, I hope version 0.13 will be released quickly. Promises are unusable without this, I force the polyfill because node 0.12 promises are missing this feature. |
I can close this now that io.js and nodejs are merging I think :) Big win for all of us. |
…node (<= 0.12) does not throw unhandled exceptions in promises... the newer node 0.13 should handle it. nodejs/node-v0.x-archive#8997
Promise unhandled rejection
It is common for promise libraries to emit possibly unhandled rejections (promise chains no
.catch
listener orthen
with a second argument is attached to).Most libraries as well as native promises in V8 support detecting these cases.
It is common for code to have multiple promise libraries, native promises and multiple copies of the same promise library included. Sometimes people are interested in hook on such unhandled rejections in order to add custom logging, terminate the process, suppress the rejection etc. - a survey (in the later linked gist) indicates that this is used in practice by users.
What I'm asking for
I'm asking for native promises to emit events on possibly unhandled rejections so that user level code can handle them to provide better debugging.
Here is the actual proposal
It is currently in the seeking feedback stage.
Effect on user APIs
None, there is no resource penalty, API changes or backwards incompatible changes introduced by this.
Implementation in userland
Since this change requires talking to the native V8 promise implementation which in turn cannot implement this itself since it is unaware of Node, there is no possibility to implement this at a user level either because the hooks are not exposed.
Non native promises (promise libraries) will implement it at a userlevel but since people are writing code that depends on native promises and they are a language feature this hook is required.
The text was updated successfully, but these errors were encountered: