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

Update blog post which creates unhandled promise rejection #9668

Merged
merged 3 commits into from
May 26, 2017

Conversation

griffinmyers
Copy link

In case anybody else stumbles across this old blog post, I wanted to submit a patch to help with unhandled rejections.

#then and #catch each return new Promise instances, so here we actually create two new promises (that aren't assigned). If the argument promise to #makeCancelable rejects, the promise created by #then will be an unhandled rejection, which in Node 7 will be an uncaught error.

By using the second argument of #then to handle rejections instead, we don't need to worry about the runtime finding any unhandled rejections here.

In case anybody else stumbles across this old blog post, I wanted to submit a patch to help with unhandled rejections.  

`#then` and `#catch` each return new Promise instances, so here we actually create two new promises (that aren't assigned).  If the argument promise to `#makeCancelable` rejects, the promise created by `#then` will be an unhandled rejection, which in Node 7 will be an uncaught error.  

By using the second argument of `#then` to handle rejections instead, we don't need to worry about the runtime finding any unhandled rejections here.
@griffinmyers griffinmyers changed the title Update 2015-12-16-ismounted-antipattern.md Update Blog Post which creates unhandled promise rejection May 16, 2017
@griffinmyers griffinmyers changed the title Update Blog Post which creates unhandled promise rejection Update blog post which creates unhandled promise rejection May 16, 2017
@gaearon gaearon merged commit 546e772 into facebook:master May 26, 2017
@gaearon
Copy link
Collaborator

gaearon commented May 26, 2017

Thanks!

gaearon pushed a commit that referenced this pull request Jun 9, 2017
* Update 2015-12-16-ismounted-antipattern.md

In case anybody else stumbles across this old blog post, I wanted to submit a patch to help with unhandled rejections.

`#then` and `#catch` each return new Promise instances, so here we actually create two new promises (that aren't assigned).  If the argument promise to `#makeCancelable` rejects, the promise created by `#then` will be an unhandled rejection, which in Node 7 will be an uncaught error.

By using the second argument of `#then` to handle rejections instead, we don't need to worry about the runtime finding any unhandled rejections here.

* Style updates

* Add update notice

(cherry picked from commit 546e772)
flarnie pushed a commit that referenced this pull request Jun 12, 2017
* Update 2015-12-16-ismounted-antipattern.md

In case anybody else stumbles across this old blog post, I wanted to submit a patch to help with unhandled rejections.

`#then` and `#catch` each return new Promise instances, so here we actually create two new promises (that aren't assigned).  If the argument promise to `#makeCancelable` rejects, the promise created by `#then` will be an unhandled rejection, which in Node 7 will be an uncaught error.

By using the second argument of `#then` to handle rejections instead, we don't need to worry about the runtime finding any unhandled rejections here.

* Style updates

* Add update notice

(cherry picked from commit 546e772)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants