What version of Bun is running?
1.3.11-canary.1+9e93bfa1b
What platform is your computer?
Linux 5.10.0-12-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below snippet
const url = 'https://example.com/';
async function test(value, label) {
try {
console.log(`Testing fetch(url, ${label})`);
await fetch(url, value);
console.log(`fetch(url, ${label}) resolved (no error thrown)`);
} catch (e) {
console.log(`fetch(url, ${label}) rejected with:`, e && e.name, e && e.message);
}
}
const not_an_object_values = [
0,
0n,
"",
false,
Symbol("test")
];
for (const v of not_an_object_values) {
const label = typeof v === 'symbol' ? 'Symbol("test")' : JSON.stringify(v.toString ? v.toString() : v);
// Intentionally pass invalid init values to trigger the bug
await test(v, label);
}
What is the expected behavior?
Node correctly prints TypeError when invalid values are passed
root@KContainer:~/8565# node fetch_poc.mjs
Testing fetch(url, "0")
fetch(url, "0") rejected with: TypeError undefined: Expected 0 to be one of: Null, Undefined, Object.
Testing fetch(url, "0")
fetch(url, "0") rejected with: TypeError undefined: Expected 0 to be one of: Null, Undefined, Object.
Testing fetch(url, "")
fetch(url, "") rejected with: TypeError undefined: Expected to be one of: Null, Undefined, Object.
Testing fetch(url, "false")
fetch(url, "false") rejected with: TypeError undefined: Expected false to be one of: Null, Undefined, Object.
Testing fetch(url, Symbol("test"))
fetch(url, Symbol("test")) rejected with: TypeError Cannot convert a Symbol value to a string
What do you see instead?
Bun does not throw any error
root@KContainer:~/8565# bun run fetch_poc.mjs
Testing fetch(url, "0")
fetch(url, "0") resolved (no error thrown)
Testing fetch(url, "0")
fetch(url, "0") resolved (no error thrown)
Testing fetch(url, "")
fetch(url, "") resolved (no error thrown)
Testing fetch(url, "false")
fetch(url, "false") resolved (no error thrown)
Testing fetch(url, Symbol("test"))
fetch(url, Symbol("test")) resolved (no error thrown)
Additional information
No response
What version of Bun is running?
1.3.11-canary.1+9e93bfa1b
What platform is your computer?
Linux 5.10.0-12-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below snippet
What is the expected behavior?
Node correctly prints TypeError when invalid values are passed
What do you see instead?
Bun does not throw any error
Additional information
No response