-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
Describe the bug
const inputData = {
Bucket: bucketName,
Key: fileKey,
Range: _range
}
try {
const getObjectCommand = new GetObjectCommand(inputData)
const s3Client = new S3Client({
region,
credentials,
})
const response = await s3Client.send(getObjectCommand)
} catch (e) {
console.log(e)
}
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:
`Checksum mismatch: expected "${this.expectedChecksum}" but received "${received}"` +
` in response header "${this.checksumSourceLocation}".`
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
- Select this option if this issue appears to be a regression.
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
const inputData = {
Bucket: this._config.bucketName,
Key: fileKey,
Range: _range
}
try {
const getObjectCommand = new GetObjectCommand(inputData)
const s3Client = new S3Client({
region,
credentials,
})
const response = await s3Client.send(getObjectCommand)
} catch (e) {
console.log(e)
}
in order to simulate checksum mismatch you can change this.expectedChecksum !== received
to this.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