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

feat: provide config idle timeout for bun runtime. #2984

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: configure idle timeout for bun runtime.
```
[Bun.serve]: request timed out after 10 seconds. Pass `idleTimeout` to configure.
```

we need to be able to configure idle timeout for bun runtime, because if there are any [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch) inside event handler sometimes need more than 10 seconds.

we can leverage built in `NITRO_SHUTDOWN_TIMEOUT ` environment variable to configure this.

references:
- https://bun.sh/docs/api/http#idletimeout
- https://nitro.build/deploy/runtimes/node#environment-variables
  • Loading branch information
jamaluddinrumi authored Jan 8, 2025
commit e59f39b9de82a3cb11cc844a5e995dddb5c35de9
1 change: 1 addition & 0 deletions src/presets/bun/runtime/bun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ws = import.meta._websocket

// @ts-expect-error
const server = Bun.serve({
idleTimeout: process.env.NITRO_SHUTDOWN_TIMEOUT || 10,
Copy link
Member

Choose a reason for hiding this comment

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

These are not exactly same options, we need bun specific environment variable for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NITRO_BUN_IDLE_TIMEOUT is good for this, isn't it?

btw, luckily, i can use bun patch to overcome this for now. so, no need to rush to fix this as soon as possible in my side.

port: process.env.NITRO_PORT || process.env.PORT || 3000,
websocket: import.meta._websocket ? ws!.websocket : (undefined as any),
async fetch(req: Request, server: any) {
Expand Down
Loading