diff options
Diffstat (limited to 'ext/http/01_http.js')
| -rw-r--r-- | ext/http/01_http.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/ext/http/01_http.js b/ext/http/01_http.js index 7620d154a..4922ed07a 100644 --- a/ext/http/01_http.js +++ b/ext/http/01_http.js @@ -17,8 +17,17 @@ const { BadResource, Interrupted } = core; const { ReadableStream } = window.__bootstrap.streams; const abortSignal = window.__bootstrap.abortSignal; - const { WebSocket, _rid, _readyState, _eventLoop, _protocol, _server } = - window.__bootstrap.webSocket; + const { + WebSocket, + _rid, + _readyState, + _eventLoop, + _protocol, + _server, + _idleTimeoutDuration, + _idleTimeoutTimeout, + _serverHandleIdleTimeout, + } = window.__bootstrap.webSocket; const { ArrayPrototypeIncludes, ArrayPrototypePush, @@ -277,6 +286,13 @@ ws.dispatchEvent(event); ws[_eventLoop](); + if (ws[_idleTimeoutDuration]) { + ws.addEventListener( + "close", + () => clearTimeout(ws[_idleTimeoutTimeout]), + ); + } + ws[_serverHandleIdleTimeout](); } } } finally { @@ -378,6 +394,8 @@ setEventTargetData(socket); socket[_server] = true; response[_ws] = socket; + socket[_idleTimeoutDuration] = options.idleTimeout ?? 120; + socket[_idleTimeoutTimeout] = null; return { response, socket }; } |
