Skip to content

Commit

Permalink
feat: configure idle timeout for bun runtime.
Browse files Browse the repository at this point in the history
```
[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
1 parent e8d6099 commit e59f39b
Showing 1 changed file with 1 addition and 0 deletions.
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,
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

0 comments on commit e59f39b

Please sign in to comment.