Skip to content

Commit fe308ab

Browse files
committedSep 13, 2022
More clearly abort refused connections downstream
Mildly more accurate proxying I think (though less technically correct) but especially useful because its the error we receive for failed proxy connections, which will imminently become relevant.
1 parent 8fad51a commit fe308ab

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎src/rules/requests/request-handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ export class PassThroughHandler extends PassThroughHandlerDefinition {
929929
}
930930
clientRes.tags.push('passthrough-error:' + e.code);
931931

932-
if (e.code === 'ECONNRESET') {
932+
if (e.code === 'ECONNRESET' || e.code === 'ECONNREFUSED') {
933933
// The upstream socket closed: forcibly close the downstream stream to match
934934
const socket: net.Socket = (clientReq as any).socket;
935935
socket.destroy();

‎test/integration/subscriptions/response-events.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ describe("Abort subscriptions", () => {
467467
await server.on('response', (r) => seenResponsePromise.resolve(r));
468468

469469
await server.forAnyRequest().thenPassThrough({
470-
proxyConfig: { proxyUrl: `http://localhost:8901` }
470+
// Wrong port: this connection will fail
471+
proxyConfig: { proxyUrl: `http://localhost:8999` }
471472
});
472473

473474
fetch(server.urlFor("/mocked-endpoint")).catch(() => {});

0 commit comments

Comments
 (0)
Failed to load comments.