From 86ed7b02cfa6aef1463e9ba446daf9db8a8567aa Mon Sep 17 00:00:00 2001 From: Samuel M-Lavoie Date: Wed, 24 Sep 2025 10:43:48 -0400 Subject: [PATCH 1/2] Emit an event when the tunnel has an error --- src/chain.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/chain.ts b/src/chain.ts index 06cd1603..045a53eb 100644 --- a/src/chain.ts +++ b/src/chain.ts @@ -190,11 +190,31 @@ export const chain = ( if (sourceSocket.readyState === 'open') { if (isPlain) { sourceSocket.end(); + + server.emit('tunnelError', { + error, + proxyChainId, + customTag, + }); } else { const statusCode = errorCodeToStatusCode[error.code!] ?? badGatewayStatusCodes.GENERIC_ERROR; const response = createCustomStatusHttpResponse(statusCode, error.code ?? 'Upstream Closed Early'); sourceSocket.end(response); + + server.emit('tunnelError', { + error, + proxyChainId, + statusCode, + response, + customTag, + }); } + } else { + server.emit('tunnelError', { + error, + proxyChainId, + customTag, + }); } }); From cc4e7d8c65a85702dd8bcb272dd2ea01ea33220b Mon Sep 17 00:00:00 2001 From: Samuel M-Lavoie Date: Wed, 24 Sep 2025 22:58:51 -0400 Subject: [PATCH 2/2] Addeed status code to tunnelConnectFailed --- src/chain.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chain.ts b/src/chain.ts index 045a53eb..f150a176 100644 --- a/src/chain.ts +++ b/src/chain.ts @@ -137,6 +137,7 @@ export const chain = ( proxyChainId, response, customTag, + statusCode: response.statusCode, socket: targetSocket, head: clientHead, }); @@ -190,7 +191,7 @@ export const chain = ( if (sourceSocket.readyState === 'open') { if (isPlain) { sourceSocket.end(); - + server.emit('tunnelError', { error, proxyChainId,