Open umairm1alik opened 1 month ago
Are you able to use a version of the ReadableStream polyfill that implements ReadableStream.prototype.tee()
?
Before implementing Chunk with '@aws-sdk/lib-storage' I was uploading media files with aws-sdk/client-s3 and it was working. Even now if the file size is smaller than 5 mb everything working properly. But giving error for above 5 mb
As @kuhe asked, are you using a version of the ReadableStream polyfill that implements ReadableStream.prototype.tee()
?
The JS SDK v3 required ReadableStream polyfill to work in react-native environment.
We added a recommendation to add web-streams-polyfill
in the documentation in https://github.com/aws/aws-sdk-js-v3/pull/6302
I'm having the same issue with version "@aws-sdk/client-s3": "^3.620.1"
and I'm already importing these in the index.js (root)
import "react-native-get-random-values";
import "react-native-url-polyfill/auto";
import "web-streams-polyfill/dist/polyfill";
Hey all - thanks everyone for reporting. I was able to reproduce the error reported. For further analysis and potential resolution, I've prepared a couple test cases along with the versions of the relevant dependencies used during our testing.
ListObjects
and PutObject
with S3
"@aws-sdk/client-s3": "^3.620.1",
"web-streams-polyfill": "^4.0.0",
"react-native-get-random-values": "^1.11.0",
"react-native-url-polyfill": "^2.0.0"
import 'react-native-get-random-values';
import 'react-native-url-polyfill/auto';
import { ReadableStream } from "web-streams-polyfill";
import "web-streams-polyfill/dist/polyfill";
globalThis.ReadableStream = ReadableStream;
ListObjects
and PutObject
: TypeError: readableStream.tee is not a function (it is undefined)
web-streams-polyfill
and error remains. npm i @aws-sdk/client-s3@3.574.0
ListTables
and PutItem
with DynamoDB"@aws-sdk/client-dynamodb": "^3.620.1",
"web-streams-polyfill": "^4.0.0",
"react-native-get-random-values": "^1.11.0",
"react-native-url-polyfill": "^2.0.0",
No error thrown for both operations.
If you're encountering the reported error with S3, please downgrade to @aws-sdk/client-s3@3.574.0
as a workaround, while we further look into it.
@aBurmeseDev thanks for the fast reply and solution. Its working with @aws-sdk/client-s3@3.574.0
- Error thrown on both
ListObjects
andPutObject
:TypeError: readableStream.tee is not a function (it is undefined)
If you're encountering the reported error with S3, please downgrade to
@aws-sdk/client-s3@3.574.0
as a workaround
I'm not able to reproduce the issue with standard code samples in https://github.com/aws-samples/aws-sdk-js-tests for S3 ListObjects with v3.575.0
The ListObjects command is successful on iOS as shown in screenshot below
I also downloaded local bundle, and verified that SDK version is v3.575.0
.
Bundle for reference: index.bundle.js.txt
Patch file for repro: test-client-s3-list-objects.patch
To repro, just follow the README of https://github.com/aws-samples/aws-sdk-js-tests, and apply the patch using git apply
.
On repro, the local bundle will be available on this URL.
If you're encountering the reported error with S3, please downgrade to @aws-sdk/client-s3@3.574.0 as a workaround, while we further look into it.
@aBurmeseDev I am still facing issues with this workaround sometimes it works fine and sometimes it still gives this error [TypeError: readableStream.tee is not a function (it is undefined)]
Thank you , Its working with @aws-sdk/client-s3@3.574.0
@umairm1alik - quick update here.
Initially, I was able to reproduce the error when using React Native with Expo. However, after starting a new React Native project without Expo, following the steps and code examples from the aws-sdk-js-tests, the issue was resolved.
This suggests that the root cause of the problem might be related to Expo itself or the way it integrates with the AWS SDK for JavaScript v3. To further investigate and identify the culprit, it would be helpful if you could share detailed steps to reproduce your workflow, including the dependencies you've installed.
Providing a step-by-step guide on how you set up your React Native project with Expo, the specific version of Expo you're using, and any other relevant dependencies or configurations, would assist in narrowing down the potential cause of the issue and determining if it's indeed related to Expo or if there are other factors at play.
Hey all - thanks everyone for reporting. I was able to reproduce the error reported. For further analysis and potential resolution, I've prepared a couple test cases along with the versions of the relevant dependencies used during our testing.
- Test Case:
ListObjects
andPutObject
with S3
- install S3 client along with third-party libraries that provide polyfills for Web Streams API in React Native
"@aws-sdk/client-s3": "^3.620.1", "web-streams-polyfill": "^4.0.0", "react-native-get-random-values": "^1.11.0", "react-native-url-polyfill": "^2.0.0"
- import libraries
import 'react-native-get-random-values'; import 'react-native-url-polyfill/auto'; import { ReadableStream } from "web-streams-polyfill"; import "web-streams-polyfill/dist/polyfill"; globalThis.ReadableStream = ReadableStream;
- Error thrown on both
ListObjects
andPutObject
:TypeError: readableStream.tee is not a function (it is undefined)
- Tested different major versions of
web-streams-polyfill
and error remains.- Downgraded to "@aws-sdk/client-s3": "^3.574.0" and the call with successful.
npm i @aws-sdk/client-s3@3.574.0
- Test Case:
ListTables
andPutItem
with DynamoDB"@aws-sdk/client-dynamodb": "^3.620.1", "web-streams-polyfill": "^4.0.0", "react-native-get-random-values": "^1.11.0", "react-native-url-polyfill": "^2.0.0",
No error thrown for both operations.
If you're encountering the reported error with S3, please downgrade to
@aws-sdk/client-s3@3.574.0
as a workaround, while we further look into it.
Finally found a solution! Thank you so much!
I am seeing this in Lambda NodeJS 20 runtime. I would like to avoid bundling AWS SDK manually though, any suggestions here?
What's funny is that file seems to be uploaded (yes, PutObject
here) without a problem.
@aBurmeseDev I am using react native CLI not expo and my version is "react-native": "0.74.1" at first, my issue was resolved with @aws-sdk/client-s3@3.574.0 but still, sometimes I was getting this issue then I updated to @aws-sdk/client-s3@3.575.0 and my issue was resolved.
Thanks for the update @umairm1alik!
It sounds like the error is intermittent for you, occurring with both @aws-sdk/client-s3@3.575.0
and @aws-sdk/client-s3@3.574.0
. This suggests that the issue may be caused by something outside of the AWS SDK itself.
As I mentioned earlier in my comment, I was able to reproduce the error when using Expo, but when I started a new plain React Native project without Expo, it worked as expected.
To further validate my theory, I attempted to reproduce the issue using the react-native reproducer provided by the React Native community. However, I was unable to reproduce the error following the instructions in the README for setting up and using the provided steps to start the Metro Server and the application.
Can you try reproducing the issue using the same reproducer and steps? Here's patch file for repro ref: test-react-native-s3-list-objects.patch
Checkboxes for prior research
Describe the bug
I am trying to implement chunk approach to upload files in react native , if the file size is less then 5 mb its working fine other wise i am getting this error
SDK version number
"@aws-sdk/client-s3": "^3.592.0", "@aws-sdk/lib-storage": "^3.620.0",
Which JavaScript Runtime is this issue in?
React Native
Details of the browser/Node.js/ReactNative version
"react-native": "0.74.1",
Reproduction Steps
index.js
AppRegistry.registerComponent(appName, () => App);
Observed Behavior
TypeError: readableStream.tee is not a function (it is undefined)
Expected Behavior
It should have to upload images , videos in chunk if its more then 5mb in size
Possible Solution
No response
Additional Information/Context
No response