Skip to content

Race conditions in S3 upload #6115

@jirimoravcik

Description

@jirimoravcik

Checkboxes for prior research

Describe the bug

We're getting errors from AWS SDK when using:

import { Upload } from '@aws-sdk/lib-storage';

We create an instance of S3 client via:

const s3Client = new S3({ apiVersion: '2016-04-01' });

then the code (where params is of type PutObjectCommandInput):

const upload = new Upload({
    client: s3Client,
    params,
});

await upload.done();

These are most likely race conditions in the SDK as we're getting weird errors at times when we perform many simultaneous uploads to S3.
Errors we have observed:

  • "name":"400","message":"UnknownError"
  • "name":"XAmzContentSHA256Mismatch","message":"The provided 'x-amz-content-sha256' header does not match what was computed."
  • "name":"Error","message":"char 'H' is not expected.:1:1\n Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object."

SDK version number

"@aws-sdk/client-s3": "3.565.0", "@aws-sdk/lib-storage": "3.565.0"

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

20.12.2

Reproduction Steps

We upgraded our node js from 14 to 20 and these errors started appearing.

Observed Behavior

Errors we have observed, which seem to be race conditions:

  1. "name":"400","message":"UnknownError"
  2. "name":"XAmzContentSHA256Mismatch","message":"The provided 'x-amz-content-sha256' header does not match what was computed."
  3. "name":"Error","message":"char 'H' is not expected.:1:1\n Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object."

Expected Behavior

No errors happening.

Possible Solution

No response

Additional Information/Context

This issue started to appear when we upgraded Node.js from version 14 to 20.

It appears someone else reported this but was ignored, see #5455

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions