Skip to content

Conversation

@apexskier
Copy link
Contributor

@apexskierapexskier commented Mar 1, 2017

The unhandled promise rejection warning uses a template literal and
prints the reason a promise was rejected. If rejecting with a symbol,
the symbol failed to convert to a string and the process crashed. Now,
symbols are casted to strings and the process does not crash.

Fixes: #11637

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • [ ] documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

process

cjihrig
cjihrig previously requested changes Mar 1, 2017
Copy link
Contributor

@cjihrigcjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a message test for this. A "normal" test in test/parallel/ that uses common.expectWarning() should do.

@mscdexmscdex added the process Issues and PRs related to the process subsystem. label Mar 1, 2017
@addaleaxaddaleax added the promises Issues and PRs related to ECMAScript promises. label Mar 2, 2017
@Fishrock123
Copy link
Contributor

@jasnell
Copy link
Member

Definitely agree that all this needs is a simple common.expectsWarning() check.

@apexskier
Copy link
ContributorAuthor

From the source and my tests, it looks like common.expectWarning() will only work if a single warning is generated in the test.

A test like the following generates two warnings with different names, so I can't ensure the warning matches. I could

'use strict';// ensure this doesn't crashPromise.reject(Symbol());
(node:95244) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Symbol() (node:95244) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 

I've got a change that allows expectWarning to take a map of names to message(s) or the original parameter types.

@cjihrig
Copy link
Contributor

Can you split the changes to test/common.js into a separate commit.

This allows the common.checkWarning() test method to accept a map of warning names to description(s), to allow testing code that generates multiple types of warnings.
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: #11637
Copy link
Member

@addaleaxaddaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleaxaddaleax dismissed cjihrig’s stale reviewApril 29, 2017 21:22

request to not have a message test has been addressed

@addaleax
Copy link
Member

Landed in 765be6c...a3132b0, thanks for the PR!

addaleax pushed a commit that referenced this pull request Apr 29, 2017
This allows the common.checkWarning() test method to accept a map of warning names to description(s), to allow testing code that generates multiple types of warnings. PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
addaleax pushed a commit that referenced this pull request Apr 29, 2017
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: #11637 PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
@evanlucasevanlucas mentioned this pull request May 1, 2017
evanlucas pushed a commit that referenced this pull request May 1, 2017
This allows the common.checkWarning() test method to accept a map of warning names to description(s), to allow testing code that generates multiple types of warnings. PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request May 1, 2017
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: #11637 PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
@bakkot
Copy link
Contributor

Symbol is only one example among many of something which throws when trying to call .toString. If I read this correctly, this PR doesn't fix the core issue, and will presumably still crash on e.g.

Promise.reject({toString(){throw0;}})

evanlucas pushed a commit that referenced this pull request May 2, 2017
This allows the common.checkWarning() test method to accept a map of warning names to description(s), to allow testing code that generates multiple types of warnings. PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request May 2, 2017
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: #11637 PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas added a commit that referenced this pull request May 2, 2017
Notable changes: * **crypto**: - add randomFill and randomFillSync (Evan Lucas) #10209 * **meta**: Added new collaborators - add lucamaraschi to collaborators (Luca Maraschi) #12538 - add DavidCai1993 to collaborators (David Cai) #12435 - add jkrems to collaborators (Jan Krems) #12427 - add AnnaMag to collaborators (AnnaMag) #12414 * **process**: - fix crash when Promise rejection is a Symbol (Cameron Little) #11640 * **url**: - make WHATWG URL more spec compliant (Timothy Gu) #12507 * **v8**: - fix stack overflow in recursive method (Ben Noordhuis) #12460 - fix build errors with g++ 7 (Ben Noordhuis) #12392 PR-URL: #12775
evanlucas pushed a commit that referenced this pull request May 2, 2017
This allows the common.checkWarning() test method to accept a map of warning names to description(s), to allow testing code that generates multiple types of warnings. PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request May 2, 2017
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: #11637 PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas added a commit that referenced this pull request May 2, 2017
Notable changes: * **crypto**: - add randomFill and randomFillSync (Evan Lucas) #10209 * **meta**: Added new collaborators - add lucamaraschi to collaborators (Luca Maraschi) #12538 - add DavidCai1993 to collaborators (David Cai) #12435 - add jkrems to collaborators (Jan Krems) #12427 - add AnnaMag to collaborators (AnnaMag) #12414 * **process**: - fix crash when Promise rejection is a Symbol (Cameron Little) #11640 * **url**: - make WHATWG URL more spec compliant (Timothy Gu) #12507 * **v8**: - fix stack overflow in recursive method (Ben Noordhuis) #12460 - fix build errors with g++ 7 (Ben Noordhuis) #12392 PR-URL: #12775
evanlucas pushed a commit that referenced this pull request May 3, 2017
This allows the common.checkWarning() test method to accept a map of warning names to description(s), to allow testing code that generates multiple types of warnings. PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas pushed a commit that referenced this pull request May 3, 2017
The unhandled promise rejection warning uses a template literal and prints the reason a promise was rejected. If rejecting with a symbol, the symbol failed to convert to a string and the process crashed. Now, symbols are casted to strings and the process does not crash. Fixes: #11637 PR-URL: #11640 Reviewed-By: Anna Henningsen <[email protected]>
evanlucas added a commit that referenced this pull request May 3, 2017
Notable changes: * **crypto**: - add randomFill and randomFillSync (Evan Lucas) #10209 * **meta**: Added new collaborators - add lucamaraschi to collaborators (Luca Maraschi) #12538 - add DavidCai1993 to collaborators (David Cai) #12435 - add jkrems to collaborators (Jan Krems) #12427 - add AnnaMag to collaborators (AnnaMag) #12414 * **process**: - fix crash when Promise rejection is a Symbol (Cameron Little) #11640 * **url**: - make WHATWG URL more spec compliant (Timothy Gu) #12507 * **v8**: - fix stack overflow in recursive method (Ben Noordhuis) #12460 - fix build errors with g++ 7 (Ben Noordhuis) #12392 PR-URL: #12775
evanlucas added a commit that referenced this pull request May 3, 2017
Notable changes: * **crypto**: - add randomFill and randomFillSync (Evan Lucas) #10209 * **meta**: Added new collaborators - add lucamaraschi to collaborators (Luca Maraschi) #12538 - add DavidCai1993 to collaborators (David Cai) #12435 - add jkrems to collaborators (Jan Krems) #12427 - add AnnaMag to collaborators (AnnaMag) #12414 * **process**: - fix crash when Promise rejection is a Symbol (Cameron Little) #11640 * **url**: - make WHATWG URL more spec compliant (Timothy Gu) #12507 * **v8**: - fix stack overflow in recursive method (Ben Noordhuis) #12460 - fix build errors with g++ 7 (Ben Noordhuis) #12392 PR-URL: #12775
imyller added a commit to imyller/meta-nodejs that referenced this pull request May 4, 2017
 Notable changes: * **crypto**: - add randomFill and randomFillSync (Evan Lucas) nodejs/node#10209 * **meta**: Added new collaborators - add lucamaraschi to collaborators (Luca Maraschi) nodejs/node#12538 - add DavidCai1993 to collaborators (David Cai) nodejs/node#12435 - add jkrems to collaborators (Jan Krems) nodejs/node#12427 - add AnnaMag to collaborators (AnnaMag) nodejs/node#12414 * **process**: - fix crash when Promise rejection is a Symbol (Cameron Little) nodejs/node#11640 * **url**: - make WHATWG URL more spec compliant (Timothy Gu) nodejs/node#12507 * **v8**: - fix stack overflow in recursive method (Ben Noordhuis) nodejs/node#12460 - fix build errors with g++ 7 (Ben Noordhuis) nodejs/node#12392 PR-URL: nodejs/node#12775 Signed-off-by: Ilkka Myller <[email protected]>
anchnk pushed a commit to anchnk/node that referenced this pull request May 6, 2017
Notable changes: * **crypto**: - add randomFill and randomFillSync (Evan Lucas) nodejs#10209 * **meta**: Added new collaborators - add lucamaraschi to collaborators (Luca Maraschi) nodejs#12538 - add DavidCai1993 to collaborators (David Cai) nodejs#12435 - add jkrems to collaborators (Jan Krems) nodejs#12427 - add AnnaMag to collaborators (AnnaMag) nodejs#12414 * **process**: - fix crash when Promise rejection is a Symbol (Cameron Little) nodejs#11640 * **url**: - make WHATWG URL more spec compliant (Timothy Gu) nodejs#12507 * **v8**: - fix stack overflow in recursive method (Ben Noordhuis) nodejs#12460 - fix build errors with g++ 7 (Ben Noordhuis) nodejs#12392 PR-URL: nodejs#12775
@sam-github
Copy link
Contributor

Should this land on 6.x?

It sounds like it fixes a crash, so should be, but it also sounds like a change in error messages.

@gibfahngibfahn mentioned this pull request Jun 15, 2017
3 tasks
@gibfahn
Copy link
Member

Should this land on 6.x?

ping

cc/ @addaleax

@addaleax
Copy link
Member

Should this land on 6.x?

@gibfahn Yes, it should. :)

@bakkot
Copy link
Contributor

people backporting this: see my above comment, which I just opened a new issue for at #13771. The fix in this PR doesn't actually handle the full extent of the problem.

@gibfahn
Copy link
Member

The fix in this PR doesn't actually handle the full extent of the problem.

Does it make things worse? As long as it doesn't regess things (and hopefully is an improvement) then it should be fine to backport.

@bakkot
Copy link
Contributor

It's definitely an improvement, just not a complete solution. And I'd expect a complete solution to subsume this one.

@gibfahn
Copy link
Member

It's definitely an improvement, just not a complete solution. And I'd expect a complete solution to subsume this one.

Sure, but any "complete solution" will be a commit on top of this one, so if we don't backport this first we'll get merge conflicts when we try to cherry-pick the complete solution.

@gibfahn
Copy link
Member

Is anyone willing to backport this to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

@TimothyGuTimothyGu mentioned this pull request Jun 20, 2017
3 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

processIssues and PRs related to the process subsystem.promisesIssues and PRs related to ECMAScript promises.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhandled promise rejection with a symbol crashes node

9 participants

@apexskier@Fishrock123@jasnell@cjihrig@addaleax@bakkot@sam-github@gibfahn@mscdex