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: fix handling generators in Readable.from#32844
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
vadzim commented Apr 14, 2020 • edited by ronag
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by ronag
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
Good spot. I'm not sure needToClose is required, just always call return() in _destroy(). Also, please add a test.
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.
Would you mind to add a unit test for this? Thanks
vadzim commented Apr 14, 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.
vadzim commented Apr 14, 2020
|
ronag commented Apr 14, 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.
Here is a "desugared" pseudo version of for-of I got from Gus Caplan: I think that's probably what we should aim for. As you've noticed the throw + return() part is tricky. |
ronag commented Apr 14, 2020
Where do you see this? Maybe? |
vadzim commented Apr 14, 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.
I'm sorry, it's quite difficult for me to understand that pseudocode. // next returns ordinary value, done = false:for(constxof{[Symbol.iterator](){returnthis},next(){console.log('next');return{value: 42,done: false}},return(){console.log('return');return{done: true}}}){console.log(x)break}// output:// next// 42// return// undefined// next returns done = true:for(constxof{[Symbol.iterator](){returnthis},next(){console.log('next');return{value: 42,done: true}},return(){console.log('return');return{done: true}}}){console.log(x)break}// output:// next// undefined// next throwsfor(constxof{[Symbol.iterator](){returnthis},next(){console.log('next');throw42},return(){console.log('return');return{done: true}}}){console.log(x)break}// output:// next// Uncaught 42It seems that |
Uh oh!
There was an error while loading. Please reload this page.
ronag commented Apr 14, 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.
What do you want to illustrate with this?
Yes, that's what we are fixing in this PR? |
vadzim commented Apr 14, 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.
I mean
|
ronag commented Apr 14, 2020
Ah, I think I understand what you mean. |
ronag commented Apr 14, 2020
What happens if you do the same thing with async iterators? |
ronag commented Apr 14, 2020
But then the problem with #32842 remains? I think looking at the for await..of would be relevant. |
vadzim commented Apr 14, 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.
Same thing happens if we use |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
vadzim commented Apr 14, 2020
We still need to deal with buffer in readable stream. |
ronag 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 once tests are added, good job!
vadzim commented Apr 14, 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.
I'll write the tests, though it can take some time cause I'm gonna cover all these mentioned edge cases. |
ronag commented Apr 14, 2020
Also, please take a look at the commit guidelines. You should use |
vadzim commented Apr 14, 2020
Sure, I'll squash my draft commits into one when the job is done. |
Uh oh!
There was an error while loading. Please reload this page.
vadzim commented Apr 14, 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.
I've added tests and it's allowed me to catch one more case. |
vadzim commented Apr 14, 2020
Actually the code does not look simpler) and the tests should remain in any case. |
426b1d6 to 6bddcf7CompareUh oh!
There was an error while loading. Please reload this page.
ronag 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
nodejs-github-bot commented Apr 15, 2020
Uh oh!
There was an error while loading. Please reload this page.
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
nodejs-github-bot commented Apr 17, 2020
vadzim commented Apr 17, 2020
@ronag@mcollina Btw, actually the code didn't contain any I guess this bugfix could be applied to node@12. Does it make sense? |
mcollina commented Apr 18, 2020
Absolutely, in due time. It will be included in the closest release of 12.x after 2 weeks of being in 13.x. |
Call iterator.return() if not all of its values are consumed. Fixes: #32842 PR-URL: #32844 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
ronag commented Apr 18, 2020
Landed in 8a3fa32 |
Call iterator.return() if not all of its values are consumed. Fixes: #32842 PR-URL: #32844 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
Call iterator.return() if not all of its values are consumed. Fixes: #32842 PR-URL: #32844 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
Call iterator.return() if not all of its values are consumed. Fixes: #32842 PR-URL: #32844 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
Call iterator.return() if not all of its values are consumed. Fixes: #32842 PR-URL: #32844 Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
benjamingr commented Jan 31, 2021
Hi, I don't understand why |
benjamingr commented Jan 31, 2021
That is - if someone creates a stream, calls |
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passescloses#32842