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

fix(serve): make error messages for invalid fetch() clearer #18260

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DonIsaac
Copy link
Contributor

What does this PR do?

Makes errors thrown when Bun.serve is passed an invalid fetch() argument clearer. Partially addresses #18255.

It looks like this issue is causing problems within SST; I don't see a fetch() function being passed to Bun.serve.

How did you verify your code works?

@robobun
Copy link

robobun commented Mar 17, 2025

Updated 8:57 PM PT - Mar 18th, 2025

@DonIsaac, your commit 9eb2216 has 2 failures in Build #13496:


🧪   try this PR locally:

bunx bun-pr 18260

return global.throwInvalidArguments("Expected fetch() to be a function", .{});
if (onRequest_.isUndefined()) {
return global.throwInvalidArguments(
"Bun.serve() requires a fetch() function to handle incoming requests. For more information, see " ++ bun_docs_url ++ "api/http#bun-serve",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought that we should accept routes and/or fetch, so this error message isn't exactly right.

also getTruthy avoids undefined already so this is not going to be hit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants