fix(ssrf): answer a pinned lookup on a later tick so a failed connect cannot crash the server

Called back at once, a connect that fails right away (no route to an IPv6 address) tore the socket down while tls.connect was still setting it up; undici saw 'fetch failed' and the socket's own error then reached no listener and ended the process. The pinned lookup now answers on the next tick, as dns.lookup does.
This commit is contained in:
Maurice
2026-11-28 18:12:39 +01:00
parent d6ce33c51c
commit 41772c0d8e
4 changed files with 81 additions and 59 deletions
+3 -2
View File
@@ -152,8 +152,9 @@ describe('createOutboundDispatcher, connections kept (the routing relay)', () =>
const lookup = (
built.agents[1] as { connect: { lookup: (h: string, o: object, cb: (...a: unknown[]) => void) => void } }
).connect.lookup;
const seen: unknown[] = [];
lookup('valhalla.liketrek.com', {}, (...args: unknown[]) => seen.push(...args));
const seen = await new Promise<unknown[]>((resolve) =>
lookup('valhalla.liketrek.com', {}, (...args: unknown[]) => resolve(args)),
);
expect(seen).toContain('203.0.113.8');
expect(seen).not.toContain('203.0.113.7');
});