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

In REPL, if response is created from a blob, then response.arrayBuffer() never resolves #49062

Closed
UlyssesZh opened this issue Aug 8, 2023 · 6 comments

Comments

@UlyssesZh
Copy link

Version

v20.5.0

Platform

Linux ulysses-legion-r70002021 5.15.0-76-generic #83~20.04.1-Ubuntu SMP Wed Jun 21 20:23:31 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

Run node in command line to enter REPL mode, then run the following:

response = new Response(new Blob([new Uint8Array([5,2,0])]));
await response.arrayBuffer(); // stuck forever

How often does it reproduce? Is there a required condition?

The code snippet above reproduces the bug steadily. However, similar codes do not produce the same bug when run them in a script file. Also, strangely, the one-liner does not reproduce the same bug (in REPL):

await new Response(new Blob([new Uint8Array([5,2,0])])).arrayBuffer(); // gets expected result

What is the expected behavior? Why is that the expected behavior?

No response

What do you see instead?

Stuck forever.

Additional information

I tried v18 and v20, and I found that the bug is only reproduceable on v20 but not on v18.

Also, there is another bug that I think is related:

// test.mjs
const response = await fetch(URL.createObjectURL(new Blob([new Uint8Array([5,2,0])])));
console.log(await response.arrayBuffer());
node test.mjs

Run this script will crash Node v20 (with exit code 13 and no output). Node v18 runs it fine expectedly.

@KhafraDev
Copy link
Member

probably duplicate of #48916

@debadree25
Copy link
Member

debadree25 commented Aug 8, 2023

The code in arrayBuffer() wasnt changed so seems unlikely to be related to #48916 does it fail on all version of v20x? on v18.x i think the blob dataqueue implementation hasn't been backported

Edit: does response use stream() to collect the array buffer by any chance

@UlyssesZh
Copy link
Author

UlyssesZh commented Aug 8, 2023

does it fail on all version of v20x?

No. I tried v20.3.1, v20.4.0, and v20.5.0, among which v20.3.1 does not have the same bug.

@debadree25
Copy link
Member

Indeed #48935 fixes this

@KhafraDev
Copy link
Member

Edit: does response use stream() to collect the array buffer by any chance

Yes it does, https://github.com/nodejs/undici/blob/c83b084879fa0bb8e0469d31ec61428ac68160d5/lib/fetch/body.js#L43-L45

@debadree25
Copy link
Member

fixed by 3224527

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants