Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
stream: remove isPromise utility function#35925
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
aduh95 commented Nov 2, 2020 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot commented Nov 2, 2020
Review requested:
|
ronag left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is an improvement? The behavior is the same?
aduh95 commented Nov 2, 2020
Yes the behavior is the same. Another way would be to change the name of the function |
benjamingr commented Nov 2, 2020
Actually the current implementation (and the one in this PR) is wrong if someone passes a It's not a big bug but promise test suites check for it. The correct implementation would be to do it in "two steps":
See here for an example |
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once.
35e4d0a to f18db47Compareaduh95 commented Nov 2, 2020
I've implemented the solution suggested by @benjamingr, PTAL. |
benjamingr left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider adding a test.
If you prefer not to - I'll add one sometime after this lands :]
aduh95 commented Nov 3, 2020
Test added! It does fail on master and not with this PR, PTAL. @ronag Have your concerns been addressed? |
aduh95 commented Nov 8, 2020
@ronag are you still blocking this or can your objection be dismissed? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nodejs-github-bot commented Nov 9, 2020
mcollina left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Landed in adae822...ad98cf0 |
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: #35925 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: #35925 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
The function was not checking if the parameter was actually a Promise instance, but if it has a `then` method. Removing the utility function in favor of a clearer `typeof` check, handling the case when the thenable throws if then method is accessed more than once. PR-URL: #35925 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
The function was not checking if the parameter was actually a Promise
instance, but if it has a
thenmethod. Removing the utility functionin favor of a clearer
typeofcheck, handling the case when thethenable throws if then method is accessed more than once.
The difference between a thenable and a
Promisemay be important when using third party library (the parameter is provided by the user) and/or whenPromise.prototype.thenvalue is changed from userland.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes