Skip to content

ListObjectsV2 times out on Node.js 26 with a chunked HTTPS response #514

Closed

Description

@tsilicani

Behavior

On macOS arm64, OSLS 3.81.1 (aws-sdk 2.1693.0) times out reading a chunked HTTPS 200 OK response to ListObjectsV2 on Node 26.13.1. The same request completes on Node 22.23.5. This may affect deploy finalization, which also calls ListObjectsV2.

Reproduce

In an empty directory, install OSLS and generate a disposable loopback TLS certificate:

npm install --no-save osls@3.81.1
openssl req -x509 -newkey rsa:2048 -nodes -days 2 -subj /CN=localhost -keyout key.pem -out cert.pem

Save as repro.cjs. It invokes the real OSLS request wrapper against a local fixture; no AWS account or credentials are needed.

repro.cjs
const assert = require('node:assert/strict');
const { once } = require('node:events');
const { readFileSync } = require('node:fs');
const { Agent } = require('node:https');
const { createServer } = require('node:tls');
const request = require('osls/lib/aws/request.js');

(async () => {
  const cert = readFileSync('cert.pem');
  const key = readFileSync('key.pem');
  const keys = Array.from({ length: 722 }, (_, i) => `assets/chunk-${i}.js`);
  const xml = '<ListBucketResult>' + keys.map((key) =>
    `<Contents><Key>${key}</Key><LastModified>2025-01-01T00:00:00Z</LastModified><ETag>"fixture"</ETag><Size>12</Size><StorageClass>STANDARD</StorageClass></Contents>`
  ).join('') + '</ListBucketResult>';
  let wire = 'HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nContent-Type: application/xml\r\nConnection: close\r\n\r\n';
  for (let i = 0; i < xml.length; i += 1024) {
    const chunk = xml.slice(i, i + 1024);
    wire += `${chunk.length.toString(16)}\r\n${chunk}\r\n`;
  }
  wire += '0\r\n\r\n';
  const server = createServer({ cert, key }, (socket) => {
    socket.on('error', () => {});
    socket.once('data', () => {
      for (let i = 0; i < wire.length; i += 1460) socket.write(wire.slice(i, i + 1460));
      socket.end();
    });
  }).listen(0, '127.0.0.1');
  const agent = new Agent({ ca: cert, servername: 'localhost' });
  try {
    await once(server, 'listening');
    const result = await request({ name: 'S3', params: {
      region: 'us-east-1', endpoint: `https://127.0.0.1:${server.address().port}`,
      credentials: { accessKeyId: 'fixture', secretAccessKey: 'fixture' },
      s3ForcePathStyle: true, maxRetries: 0, httpOptions: { agent, timeout: 500 },
    } }, 'listObjectsV2', { Bucket: 'fixture-bucket' });
    assert.deepEqual(result.Contents.map(({ Key }) => Key), keys);
    console.log(`OK: ${keys.length} keys`);
  } finally {
    agent.destroy();
    server.close();
  }
})().catch((error) => { console.error(error.code ?? error); process.exitCode = 1; });

With each Node version, run:

SLS_AWS_REQUEST_MAX_RETRIES=0 node repro.cjs
  • Expected: OK: 722 keys on both versions.
  • Actual: Node 22 prints OK: 722 keys (3/3 runs); Node 26 exits with AWS_S3_LIST_OBJECTS_V2_TIMEOUT_ERROR (3/3 runs).

Related: #42. The reproducer does not assume which layer should fix the response handling.

Activity

  1. GrahamCampbell commented on Nov 21, 2026

    @GrahamCampbell
    Contributor

    Thanks for the precise reproducer. This comes from the AWS SDK v2 that osls v3 still uses: it calls read() once per readable event, and Node.js 26 changed read() to return one buffered chunk at a time (nodejs/node#60441), so the rest of the body is never consumed. That SDK is end-of-support and will not be fixed. osls v4 uses the AWS SDK v3 and completes the same fixture on Node.js 26, so please upgrade to v4, or stay on Node.js 24 with v3.

  2. GrahamCampbell commented on Nov 21, 2026

    @GrahamCampbell
    Contributor

    I've added a clarification to our README in #515.

  3. tsilicani commented on Nov 21, 2026

    @tsilicani
    Author

    Thanks for the quick response, for confirming the cause against the reproducer, and for updating the README. We appreciate your work on OSLS! We will evaluate v4 on Node 26 against an existing staging stack first. Is an in-place update the expected migration path when the service, stage, region, deployment bucket, and CloudFormation logical IDs stay unchanged, or are there any stack-state caveats beyond the migration guide?

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions