diff --git a/test/sso-only.test.mjs b/test/sso-only.test.mjs index 0c25e9ac..779d0f8a 100644 --- a/test/sso-only.test.mjs +++ b/test/sso-only.test.mjs @@ -52,7 +52,11 @@ async function stack({config = () => V2()} = {}) { await new Promise((r) => remote.listen(0, '127.0.0.1', r)) const req = (port, {method = 'GET', path = '/', headers = {}, body} = {}) => new Promise((resolve, reject) => { - const r = http.request({host: '127.0.0.1', port, method, path, headers: {host: HOST, ...headers, ...(body ? {'content-type': 'application/json', 'content-length': Buffer.byteLength(body)} : {})}}, (res) => { + // A fresh connection per request. When the gate closes it destroys every remote socket, + // keep-alive sockets included (server/app.mjs). On Node 26 the client's keep-alive agent can + // hand one of those sockets to the next request before it has read the reset, and that request + // fails with ECONNRESET ("socket hang up"). Node 22 and 24 open a new connection there instead. + const r = http.request({host: '127.0.0.1', port, agent: false, method, path, headers: {host: HOST, ...headers, ...(body ? {'content-type': 'application/json', 'content-length': Buffer.byteLength(body)} : {})}}, (res) => { let text = '' res.on('data', (c) => (text += c)) res.on('end', () => resolve({status: res.statusCode, headers: res.headers, text}))