Uh oh!
There was an error while loading. Please reload this page.
stream: fix handling generators in Readable.from - #32844
Conversation
Uh oh!
There was an error while loading. Please reload this page.
mcollina
left a comment
There was a problem hiding this comment.
Would you mind to add a unit test for this? Thanks
vadzim
commented
Apr 14, 2020
|
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? |
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.
What do you want to illustrate with this?
Yes, that's what we are fixing in this PR? |
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. |
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.
LGTM once tests are added, good job!
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.
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.
nodejs-github-bot
commented
Apr 15, 2020
Uh oh!
There was an error while loading. Please reload this page.
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. |
ronag
commented
Apr 18, 2020
Landed in 8a3fa32 |
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