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

Node incompatibility: TypeError: fetch() URL is invalid #5798

Closed
pubkey opened this issue Sep 20, 2023 · 3 comments
Closed

Node incompatibility: TypeError: fetch() URL is invalid #5798

pubkey opened this issue Sep 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@pubkey
Copy link

pubkey commented Sep 20, 2023

What version of Bun is running?

1.0.2+37edd5a6e389265738e89265bcbdf2999cb81a49

What platform is your computer?

Linux 6.2.0-32-generic x86_64 x86_64

What steps can reproduce the bug?

  1. Create a test.js file with the following content:
async function run() {
    const myBlob = new Blob(['foobar'], {
        type: 'text/plain'
    });
    const fetchUrl = URL.createObjectURL(myBlob);
    const arrayBuffer = await fetch(fetchUrl).then(res => res.arrayBuffer());
    console.dir(arrayBuffer);
}
run();
  1. run the file with bun test.js

What is the expected behavior?

It should run and transfrom the blob object into an array buffer.
In node.js it works and logs an ArrayBuffer Object.

What do you see instead?

1 | async function run() {
2 |     const myBlob = new Blob(['foobar'], {
3 |         type: 'text/plain'
4 |     });
5 |     const fetchUrl = URL.createObjectURL(myBlob);
6 |     const arrayBuffer = await fetch(fetchUrl).then(res => res.arrayBuffer());
                                  ^
TypeError: fetch() URL is invalid
 code: "ERR_INVALID_ARG_VALUE"

      at /home/xxx/test.js:6:30
      at run (/home/xxx/test.js:1:18)
      at /home/xxx/test.js:9:0

Additional information

No response

@pubkey pubkey added the bug Something isn't working label Sep 20, 2023
@Jarred-Sumner
Copy link
Collaborator

URL.createObjectURL is not implemented yet

@pubkey
Copy link
Author

pubkey commented Sep 20, 2023

@Jarred-Sumner Thank you, I didnt know that. But shouldn't URL.createObjectURL() throw instead of the later fetch() call?

@Electroid
Copy link
Contributor

We'll be tracking support for this here:
Duplicate of #3925

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

No branches or pull requests

3 participants