#3002·nock

nock@14: client request hangs (never resolves) when server aborts connection on oversized header (HPE_HEADER_OVERFLOW / 431)

Author: Magoli1Created Aug 27, 2026Updated Sep 13, 2026
Labelspull request welcome

Since upgrading nock 13.5.6 → 14.0.17, a client request that triggers a server-side connection abort on an oversized header no longer receives the server's 431 response — the request hangs forever. Merely importing nock (which activates the interceptor) is enough; no interceptor is registered for the target. Under nock 13 the same request resolves with status 431.

This looks related to the @mswjs/interceptors rewrite in v14 (cf. #3001, #2918, #2919), but covers a distinct path: the server destroying the socket after HPE_HEADER_OVERFLOW.

Minimal reproduction

node repro.mjs, deps: nock@14, supertest:

javascript
import nock from 'nock';       // activates the interceptor by import
import http from 'http';
import request from 'supertest';

const server = http.createServer({ maxHeaderSize: 64000 }, (_req, res) => {
  res.writeHead(200);
  res.end('ok');
});

const big = 'a'.repeat(64001); // exceeds maxHeaderSize
const res = await request(server).get('/').set('test', big);
console.log('status', res.status);
  • nock 13.5.6: prints status 431
  • nock 14.0.17: hangs indefinitely (no response, no error)

Also reproduces with a raw http.request client and with a socket.io upgrade request. nock.enableNetConnect(/127\.0\.0\.1|localhost/) does not help; only nock.restore() restores the correct behavior.

Environment

  • nock 14.0.17
  • Node.js v22.22.3
  • @mswjs/interceptors 0.41.x