From c518e7eba92878f9553730f8ace76a1ada52a4f1 Mon Sep 17 00:00:00 2001 From: gimenes Date: Mon, 5 Aug 2024 17:31:33 -0300 Subject: [PATCH 1/2] send out signal --- server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/server.ts b/server.ts index 0818a7d..071d46b 100644 --- a/server.ts +++ b/server.ts @@ -117,6 +117,7 @@ export const serveHandler = ( } catch (_err) { // ignore } finally { + ch.out.close(); delete serverStates[clientId]; for (const host of hosts) { if (hostToClientId[host] === clientId) { From c7957513f20ffc9dadb4acd4f5af45f40f109801 Mon Sep 17 00:00:00 2001 From: gimenes Date: Mon, 5 Aug 2024 18:58:24 -0300 Subject: [PATCH 2/2] fix close --- channel.ts | 4 ++-- server.ts | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/channel.ts b/channel.ts index d2f5708..28ff12a 100644 --- a/channel.ts +++ b/channel.ts @@ -12,11 +12,11 @@ export interface Channel { export const link = (...signals: AbortSignal[]): AbortSignal => { const ctrl = new AbortController(); for (const signal of signals) { - signal.onabort = (evt) => { + signal.addEventListener("abort", (evt) => { if (!ctrl.signal.aborted) { ctrl.abort(evt); } - }; + }); } return ctrl.signal; }; diff --git a/server.ts b/server.ts index 071d46b..0818a7d 100644 --- a/server.ts +++ b/server.ts @@ -117,7 +117,6 @@ export const serveHandler = ( } catch (_err) { // ignore } finally { - ch.out.close(); delete serverStates[clientId]; for (const host of hosts) { if (hostToClientId[host] === clientId) {