-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled 'error' event caused by ChecksumStream #6845
Comments
Hey @agaevaslan , I can't reproduce this issue. I'm using "@aws-sdk/client-s3": "3.732", import {S3Client, GetObjectCommand} from "@aws-sdk/client-s3"
import {NodeHttpHandler} from "@smithy/node-http-handler"
const client = new S3Client({
region : "us-east-1",
requestHandler: new NodeHttpHandler({
connectionTimeout: 5000, // 5 seconds
requestTimeout: 5000
})
});
const res = await client.send(new GetObjectCommand({
Bucket: "new-bucket-maggie-ma",
Key: "0.txt",
Range: "bytes=1-"
}))
const bodyContents = await res.Body.transformToString();
console.log('File contents:', bodyContents);
console.log("res", res.$metadata, res.$metadata.response); The result I got -
Could you please provide more details with minimal reprod? |
hey @zshzbh , But you can simulate the mismatch by always returning an error in
I'm pretty sure this is where the error is generated since it's the only place in the package with such error message. |
We are planning to release a fix for this issue today in a few hours. |
This should be fixed as of https://github.com/aws/aws-sdk-js-v3/releases/tag/v3.735.0 with |
Checkboxes for prior research
Describe the bug
when getting a filestream from s3 with GetObjectCommand, if there's a checksum mismatch in
@aws-sdk/middleware-flexible-checksums/node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.js
the error is thrown:this error causes from
Unhandled 'error' event
in ChecksumStream.It's not catched in catch block around
s3Client.send(getObjectCommand)
(since it happens after receiving the result after the response stream (response.Body
starts producing data) and causes an unhandled exception.There seems to be no way to catch/handle it (except using global unhandled expection handlers).
Regression Issue
SDK version number
@aws-sdk/client-s3 v3.732.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.18.1
Reproduction Steps
in order to simulate checksum mismatch you can change
this.expectedChecksum !== received
tothis.expectedChecksum === received
or smth trueish in@aws-sdk/middleware-flexible-checksums/node_modules/@smithy/util-stream/dist-cjs/checksum/ChecksumStream.js
.Observed Behavior
Checksum mismatch error causes unhandled error event
Expected Behavior
Checksum mismatch error should not cause unhandled error event
Possible Solution
Expose ChecksumStream outside to allow setting error handlers
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: