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

fetch a long base64 url will crash and nothing happens #1574

Closed
ahaoboy opened this issue Jul 25, 2022 · 4 comments
Closed

fetch a long base64 url will crash and nothing happens #1574

ahaoboy opened this issue Jul 25, 2022 · 4 comments
Labels
bug Something isn't working fetch good first issue Good for newcomers

Comments

@ahaoboy
Copy link
Contributor

ahaoboy commented Jul 25, 2022

Version

v18.6.0

Platform

Darwin C02G87AYMD6R 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

Subsystem

macos

What steps will reproduce the bug?

node test.js

async function test(n) {
  const s = "a".repeat(n);
  const base64 = Buffer.from(s).toString("base64");
  const dataURIPrefix = "data:application/octet-stream;base64,";
  const url = dataURIPrefix + base64;
  const resp = await fetch(url);
  const buf = await resp.arrayBuffer();
  const str = Buffer.from(buf).toString("ascii");
  console.log(str === s);
}

test(1 << 10); // true
test(1 << 20); // nothing happens
test(1 << 15); // true

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

always reproduce

What is the expected behavior?

expect log true always or throw error

What do you see instead?

when url is long enough, fetch is crash and nothing happen

Additional information

No response

@targos
Copy link
Member

targos commented Jul 25, 2022

@nodejs/undici ?

@targos targos added the fetch label Jul 25, 2022
@mcollina mcollina transferred this issue from nodejs/node Jul 25, 2022
@mcollina
Copy link
Member

Moved to the undici repo.

@mcollina mcollina added bug Something isn't working good first issue Good for newcomers labels Jul 25, 2022
@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@ahaoboy
Copy link
Contributor Author

ahaoboy commented Jul 25, 2022

@mcollina
#1575

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fetch good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants