diff options
author | Timo Wilhelm <mail@timowilhelm.com> | 2023-03-15 23:37:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 22:37:06 +0000 |
commit | 92c3ac30346fddc138a5d83cb67c87ac23e69dae (patch) | |
tree | 630bfe627293968f78582eb1eecc34bc2c085281 /ext/http/01_http.js | |
parent | 1c285ac214ff843a04e76fd6e9669bd8e809748c (diff) |
fix(ext/http): abort request signal when response errors (#17822)
Diffstat (limited to 'ext/http/01_http.js')
-rw-r--r-- | ext/http/01_http.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ext/http/01_http.js b/ext/http/01_http.js index fee30f7f0..7e648017b 100644 --- a/ext/http/01_http.js +++ b/ext/http/01_http.js @@ -18,7 +18,7 @@ import { fromInnerRequest, newInnerRequest, } from "ext:deno_fetch/23_request.js"; -import * as abortSignal from "ext:deno_web/03_abort_signal.js"; +import { AbortController } from "ext:deno_web/03_abort_signal.js"; import { _eventLoop, _idleTimeoutDuration, @@ -135,10 +135,10 @@ class HttpConn { body !== null ? new InnerBody(body) : null, false, ); - const signal = abortSignal.newSignal(); + const abortController = new AbortController(); const request = fromInnerRequest( innerRequest, - signal, + abortController.signal, "immutable", false, ); @@ -149,6 +149,7 @@ class HttpConn { request, this.#remoteAddr, this.#localAddr, + abortController, ); return { request, respondWith }; @@ -185,6 +186,7 @@ function createRespondWith( request, remoteAddr, localAddr, + abortController, ) { return async function respondWith(resp) { try { @@ -381,6 +383,9 @@ function createRespondWith( } ws[_serverHandleIdleTimeout](); } + } catch (error) { + abortController.abort(error); + throw error; } finally { if (SetPrototypeDelete(httpConn.managedResources, streamRid)) { core.close(streamRid); |