aws-sdk-js-v3: Angular 19 PutObjectRequest readableStream.getReader is not a function
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
Hi, I have an Angular application that I recently updated to version 19, and during this migration I also updated aws-sdk/client-s3 to version 3.731.1.
Before the migration the following code worked fine allowing me to upload files to S3. However, now the same code throws the exception TypeError: readableStream.getReader is not a function.
store(filename: string, data: Blob, folder: string): Promise<string> {
const weakThis = this;
return new Promise<string>(async (resolve, reject) => {
try {
const input: PutObjectRequest = {
ACL: 'public-read',
Bucket: this.awsBucket,
Key: `${folder}/${filename}`,
Body: data,
}
const command = new PutObjectCommand(input);
const resp = await weakThis.client.send(command);
if (resp.$metadata.httpStatusCode < 200 || resp.$metadata.httpStatusCode > 299) {
this.logger.error(`[AwsFileService][store] Error storing file at path ${key}`);
this.logger.error(`[AwsFileService][store] HTTP Status ${resp.$metadata.httpStatusCode}`);
reject(resp.$metadata.httpStatusCode);
return;
}
resolve(key);
} catch (error) {
debugger;
console.log(`[AwsFileService][store] Error storing file at path ${key}`);
this.logger.error(`[AwsFileService][store] Error storing file at path ${key}`);
console.log(`[AwsFileService][store] ${error}`);
this.logger.error(`[AwsFileService][store] ${error}`);
reject(error);
}
});
}
Interestingly when I run the Angular application via ng serve this code works as expected. However, when I attempt to build a production copy of the application via ng build, and then run as a standard Node JS application that the issue occurs.
Environment: Node.js: 22.12.0 Angular: 19.1.2 TypeScript: 5.7.3 aws-sdk/client-s3: 3.731.1"
Regression Issue
- Select this option if this issue appears to be a regression.
SDK version number
@aws-sdk/client-s3@3.731.1
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
22.12.0
Reproduction Steps
- Create a typical Angular 19 application
- Install aws-sdk/client-s3
- Add code above in description
- Test 1: run
ng serve - Test 2: run
ng build
Observed Behavior
Test 1: File uploads successfully Test 2: Exception is thrown.
Expected Behavior
Test 1: File uploads successfully Test 2: File uploads successfully
Possible Solution
No response
Additional Information/Context
No response
UPDATE
I am thinking the original Test 1 scenario is not valid. Since posting this I changed the version of aws-sdk/client-s3 back to 3.32.0 (last known working version), and now I’m able to replicate the issue regardless of how the app is built. I have switched back to 3.731.1 and am able to replicate the issue both with ng serve and ng build
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 6
- Comments: 15 (5 by maintainers)
Commits related to this issue
- fix: rollback client-s3 (https://github.com/aws/aws-sdk-js-v3/issues/6834) — committed to mradigen/balti by mradigen 2 years ago
- fix: rollback client-s3 (https://github.com/aws/aws-sdk-js-v3/issues/6834) — committed to mradigen/kachra by mradigen 2 years ago
As @aBurmeseDev mentioned, the simplest workaround at the time of comment is to disable checksum computation by setting the following configuration during client creation
If the files are not huge, you can convert them to ArrayBuffer too. It’s going to read all bytes into memory though, as per specification.
I’ll raise this issue internally with the team on Mon, Jan 27th, and provide an update.
Hi @mike-appvision - thanks for reaching out and for your patience while we look into it.
I noticed you mentioned files were uploaded successfully on Test 1 and failed on Test 2. Could you elaborate on that?
During my attempt to replicate the issue, I was able to reproduce the error in first few uploads and then it started to upload successfully. Here’s my repro for reference: https://github.com/aBurmeseDev/aws-sdk-js-s3-angular
In the meantime, here are a few workarounds we’d like to suggest here:
string | Uint8Array | ReadableStreamOptionalType | BlobOptionalType. (ref)You may also be able to providepolyfillfor the API being used.Hope it helps! cc: @partheev @wis-dev
For googlers, I experienced this uploading files from Cloudflare Workers. Downgrading and pinning at
3.726.1was enough.Thank you for replying! While the latest version of the SDK is still broken, you pointing me to version
3.617.0has allowed me to patch the issue so my clients can now upload photos. Short term fix for sure, but at least we can upload photos again!Still occurs for me as of 3.844.0. I did try the workaround below, but it’s not ideal. When do you all think we can see an actual solution to the issue?
https://github.com/aws/aws-sdk-js-v3/issues/6834#issuecomment-2613306914
Facing this error in React 19 (Vite) as well:-
TypeError: readableStream.getReader is not a function@aws-sdk/client-s3 version is 3.749.0
This problem also occurs in
React.js + Next.jsenvironment. An error occurs when uploading an image to S3 from the browser.@aws-sdk/client-s3: It worked normally in3.726.1, but an error occurs in later versions.Error
I use Angular 18 and encountered the same issue. As @wis-dev said,
3.726.1works.