Skip to content

s3 GetObject OOM issues with streaming large objects #7657

@jasperlin451

Description

@jasperlin451

Checkboxes for prior research

Describe the bug

We upgraded from 3.835 to 3.958 and now using GetObjectCommand to stream large (multi-GB) objects is causing OOM issues.

Explicitly turning responseChecksumValidation to WHEN_REQUIRED fixed the OOM issue.

I know the behavior checksum behavior changed w/ 3.729.0 but that doesn't seem to be the cause here.

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/client-s3@3.958.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.19.0

Reproduction Steps

async function main() {
  const client = new S3Client({
      // responseChecksumValidation: 'WHEN_REQUIRED', -- set this to fix
    });

   const { Body: readable } = await this.client.send(
      new GetObjectCommand({
        Bucket: //bucket,
        Key: // path to very large file,
      })
    );

  if (!readable) {
    throw new Error('Failed to get readable stream');
  }

  let seenBytes = 0;
  const logEvery = 50 * 1024 * 1024; // 50 MB
  let nextLog = logEvery;

  const meter = new Transform({
    transform(chunk, _enc, cb) {
      seenBytes += chunk.length;
      if (seenBytes >= nextLog) {
        const m = process.memoryUsage();
        console.log('stream progress', {
          seenMB: Math.round(seenBytes / 1024 / 1024),
          rssMB: Math.round(m.rss / 1024 / 1024),
          heapMB: Math.round(m.heapUsed / 1024 / 1024),
        });
        nextLog += logEvery;
      }
      cb(null, chunk);
    },
  });

  const devNull = new Transform({
    transform(_chunk, _enc, cb) {
      cb();
    },
  });

  await pipeline(readable, createZstdDecompress(), meter, devNull);
}

main();

Observed Behavior

OOM

Expected Behavior

No OOM when streaming

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closing-soonThis issue will automatically close in 4 days unless further comments are made.p2This is a standard priority issuepotential-regressionMarking this issue as a potential regression to be checked by team member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions