-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Reject with error when invalid fetch() body #2047
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
Conversation
|
Update: Okay, just verified it compiles and the test passes! |
test/bun.js/fetch.test.js
Outdated
| await fetch(url, { body: "buntastic" }); | ||
| expect(false).toBe(true); | ||
| } catch (exception) { | ||
| expect(exception instanceof TypeError); |
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.
| expect(exception instanceof TypeError); | |
| expect(exception instanceof TypeError).toBe(true); |
We haven't implemented expect(exception).toBeInstanceOf(TypeError) yet
|
Looks good, one nitpicky comment and then I'll merge |
|
Ah it looks like |
|
Any idea what's happening here? I modified the code in fetch("https://www.google.com", { body: "hello" }).catch(err => {
console.log(err);
console.log(err instanceof TypeError);
});I get this output: $ packages/debug-bun-darwin-*/bun-debug hello.js
1 | fetch("https://www.google.com", { body: "hello" }).catch((err) => {
^
TypeError: fetch() request with GET/HEAD/OPTIONS method cannot have body.
code: "ERR_INVALID_ARG_VALUE"
at /Users/ezhang/Documents/Work/bun/hello.js:1:0
falseEven though it prints out and displays as a |
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.
Looks good to me, thank you!
|
Oh, just FYI the fetch test I added in this PR is still failing @jwhear — not sure if you saw the comment I made above in thread. I was asking for advice on how to resolve that failing test. |
|
Ah, the |
|
I think the problem is that we are creating our own |

This is a draft PR since I can't figure out how to compile bun on my computer yet! Will work that out and then run tests to make sure it actually builds and runs.
Resolves #2014