Skip to content

https: pipelined request during a response drain fails with HPE_PAUSED #67455

Open

Description

@ajeetdsouza

Version

v26.13.1

Platform

Darwin foo.local 27.2.0 Darwin Kernel Version 27.2.0: Wed Oct 14 23:44:56 PDT 2026; root:xnu-13432.41.4~25/RELEASE_ARM64_T6041 arm64

Subsystem

http, tls

What steps will reproduce the bug?

$ openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 1 -subj /CN=localhost
$ node repro.js
const fs = require('fs');
const https = require('https');
const tls = require('tls');

const server = https.createServer({
  key: fs.readFileSync('key.pem'),
  cert: fs.readFileSync('cert.pem'),
}, (req, res) => {
  if (req.method === 'GET') {
    // Sends a response too large to flush at once, so the socket must drain.
    // While it drains, the server pauses reading and parsing to apply
    // backpressure to pipelined requests.
    res.end(Buffer.alloc(1e7));
  } else {
    // Reaching the end of the POST body means it was parsed after the drain.
    req.resume().on('end', () => process.exit(console.log('ok')));
  }
});

// On the bug, the paused parser rejects the POST body and the server destroys
// the connection.
server.on('clientError', (err) => process.exit(console.log(err.code)));

server.listen(0, () => {
  const client = tls.connect({ port: server.address().port, rejectUnauthorized: false });
  client.write('GET / HTTP/1.1\r\nHost: x\r\n\r\n');

  // Pipelines a POST once the GET response starts, while it is still draining.
  // The POST headers pause the server, but its 100 KB body spans several TLS
  // records that can arrive in one TCP read. TLS keeps delivering those
  // records after the pause, and they hit the paused parser.
  client.once('data', () => {
    client.write(`POST / HTTP/1.1\r\nHost: x\r\nContent-Length: 100000\r\n\r\n${'x'.repeat(1e5)}`);
  });
});

How often does it reproduce? Is there a required condition?

The script above reproduces the failure every time.

What is the expected behavior? Why is that the expected behavior?

ok. Plain HTTP waits for the first response to drain, then reads the POST.

What do you see instead?

HPE_PAUSED, and the server destroys the connection.

Additional information

Pausing a TLS socket stops TCP reads, but TLSWrap still delivers records it has already decrypted. Those bytes reach the paused parser, which fails with HPE_PAUSED.

Activity

  1. inoway46 commented on Nov 14, 2026

    @inoway46
    Contributor

    Reproduced on the latest v26 and nightly, as well as the older release lines I tested. This looks worth fixing, though the practical impact seems limited to HTTP/1.1 pipelining over TLS. I could also reproduce it with Undici configured for pipelining, but its retry recovered the request. I’d treat this as a normal-priority bug.

  2. added
    tlsIssues and PRs related to the tls subsystem.
    httpIssues and PRs related to the http subsystem.
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    httpIssues and PRs related to the http subsystem.tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions