Skip to content

Commit

Permalink
fix(ext/websocket): change default idleTimeout to 30s (denoland#23985)
Browse files Browse the repository at this point in the history
Change the default server websocket `idleTimeout` to 30s to work with common Nginx setups which have a default timeout of 60 seconds
  • Loading branch information
alexgleason committed May 26, 2024
1 parent 0ef1c77 commit f8975a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cli/tsc/dts/lib.deno.ns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5730,7 +5730,7 @@ declare namespace Deno {
* `pong` within the timeout specified, the connection is deemed
* unhealthy and is closed. The `close` and `error` event will be emitted.
*
* The unit is seconds, with a default of 120.
* The unit is seconds, with a default of 30.
* Set to `0` to disable timeouts. */
idleTimeout?: number;
}
Expand Down
3 changes: 2 additions & 1 deletion ext/http/02_websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ function upgradeWebSocket(request, options = { __proto__: null }) {
const socket = createWebSocketBranded(WebSocket);
setEventTargetData(socket);
socket[_server] = true;
socket[_idleTimeoutDuration] = options.idleTimeout ?? 120;
// Nginx timeout is 60s, so default to a lower number: https://github.com/denoland/deno/pull/23985
socket[_idleTimeoutDuration] = options.idleTimeout ?? 30;
socket[_idleTimeoutTimeout] = null;

if (inner._wantsUpgrade) {
Expand Down

0 comments on commit f8975a8

Please sign in to comment.