From bd7ef8152f14da4c68151659088ea267dd0fae56 Mon Sep 17 00:00:00 2001 From: Andrey Puzankov Date: Wed, 8 Nov 2023 00:07:42 +0800 Subject: [PATCH] Fix `transport.once` listener for timeout event --- lib/server.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/server.js b/lib/server.js index c4120b94..4f928a5b 100644 --- a/lib/server.js +++ b/lib/server.js @@ -65,12 +65,9 @@ class Client extends EventEmitter { this.destroy(); transport.server.clients.delete(this); }); - const timeoutHandler = () => { - if (transport instanceof HttpTransport) - transport.off('timeout', timeoutHandler); + transport.once('timeout', () => { abortable.abort('Request Timeout'); - }; - transport.once('timeout', timeoutHandler); + }); abortable.once('aborted', (error) => { if (transport instanceof HttpTransport) { error.code = error.httpCode = 408;