From e59f39b9de82a3cb11cc844a5e995dddb5c35de9 Mon Sep 17 00:00:00 2001 From: Jamaluddin Rumi Date: Thu, 9 Jan 2025 03:11:25 +0700 Subject: [PATCH] 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 --- src/presets/bun/runtime/bun.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/presets/bun/runtime/bun.ts b/src/presets/bun/runtime/bun.ts index d3f0eb05a9..8c862f9453 100644 --- a/src/presets/bun/runtime/bun.ts +++ b/src/presets/bun/runtime/bun.ts @@ -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) {