-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Bun.serve throw Error log on async #1435
Comments
const server = Bun.serve({
async fetch() {
throw new Error("Oops!");
return new Response("Unreachable");
},
error() {
return new Response("Works!");
}
});
const response = await server.fetch(new Request("http://localhost:3000/hello"));
console.log(await response.text());
server.stop(); |
Here is the output of the code that was provided. Codeconst server = Bun.serve({
async fetch() {
throw new Error("Oops!");
return new Response("Unreachable");
},
error() {
return new Response("Works!");
}
});
const response = await server.fetch(new Request("http://localhost:3000/hello"));
console.log(await response.text());
server.stop();
Code was run using the latest build of Bun. |
we should check if this still happens |
Thanks~ Doesn't happen on my end using Bun 0.5.7. |
Hey there! This issue is still reproducible on the 1.0 release. Please keep an eye on it. Thanks! |
bump, I can also reproduce the issue in 1.0.1 and 1.0.2 version of the bun. |
still reproducible on 1.0.8 any luck on this? |
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Bun is running?
0.2.2
What platform is your computer?
Darwin 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64 arm
What steps can reproduce the bug?
According to the doc, in the fetch function we can
throw new Error("")
then handle the error inerror()
method.This works as expected, it produces no error log because it's handled via
![Screenshot 2565-11-01 at 19 08 05](https://user-images.githubusercontent.com/35027979/199230183-5bd65480-c3b2-4e0e-b98c-fadbf3b6d916.png)
error()
.But when
fetch
is async, the request is finished but then there would be an error log.This would have a problem with:
bun wiptest
, the test will fail.How often does it reproduce? Is there a required condition?
This always happens when using
fetch
as asyncWhat is the expected behavior?
Throwing
error
inBun.serve
should have the same behavior in both sync and async, and the test suite should not fail when an error is thrown when using async witherror
handler.What do you see instead?
An error log.
![Screenshot 2565-11-01 at 19 07 29](https://user-images.githubusercontent.com/35027979/199230755-bc512cf5-102d-448f-97b8-28b63bbc74b4.png)
Additional information
No response
The text was updated successfully, but these errors were encountered: