Open assertnotnull opened 6 months ago
Hi @assertnotnull ,
Can you please update a small github repository with all the files needed to reproduce this behavior?
Thanks, Ran~
This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.
Ok yeah I will do a small repo
Repo is here https://github.com/assertnotnull/expo-aws-sdk-bug
@assertnotnull did you ever sort this out?
In our CJS distribution for @aws-sdk/client-dynamodb
, which is what we expect react-native to use for reasons originating in the metro bundler, we have the following platform specific files
/dist-cjs/runtimeConfig.js
/dist-cjs/runtimeConfig.native.js
When operating in react-native, the SDK relies on the behavior described here https://reactnative.dev/docs/platform-specific-code#native-specific-extensions-ie-sharing-code-with-nodejs-and-web that automatically loads the .native.js
file instead of the regular file.
In the code sample, expo has not loaded the right file, and therefore the SDK is calling Node.js filesystem module APIs like readFile
.
I don't know how to configure this on the expo/metro side, but the solution will involve loading the .native.js
file.
One workaround I can think of is to create a react-native bundle containing the AWS SDK using only the metro bundler, and then loading that in the expo application instead of using expo itself to bundle.
Checkboxes for prior research
Describe the bug
In an expo project initializing the dynamodb client gives an error
SDK version number
@aws-sdk/client-dynamodb@3.515.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
node 20, expo v50, react-native 0.73.2
Reproduction Steps
write an api route and call it from.
/app/api/messages+api.ts
Observed Behavior
Running the project through
expo start
the client initialization gives an error:Expected Behavior
No error
Possible Solution
No response
Additional Information/Context
No response