Skip to content
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

Broken import for datastore-storage-adapter on fresh Expo RN app #12801

Open
3 tasks done
myfoostrong opened this issue Jan 5, 2024 · 17 comments · May be fixed by #13083
Open
3 tasks done

Broken import for datastore-storage-adapter on fresh Expo RN app #12801

myfoostrong opened this issue Jan 5, 2024 · 17 comments · May be fixed by #13083
Assignees
Labels
bug Something isn't working DataStore Related to DataStore category

Comments

@myfoostrong
Copy link

myfoostrong commented Jan 5, 2024

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Authentication, REST API, DataStore, Storage

Amplify Version

v6

Amplify Categories

auth, storage, api, Not applicable

Backend

Amplify CLI

Environment information

# Put output below this line
System:
    OS: macOS 13.4.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 38.96 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    Yarn: 1.22.21 - ~/.nvm/versions/node/v18.19.0/bin/yarn
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
    Watchman: 2023.12.04.00 - /usr/local/bin/watchman
  Browsers:
    Chrome: 120.0.6099.199
    Safari: 16.5.2
  npmPackages:
    @aws-amplify/datastore-storage-adapter: ^2.1.10 => 2.1.10 
    @aws-amplify/react-native: ^1.0.10 => 1.0.10 
    @babel/core: ^7.20.0 => 7.23.7 
    @react-native-async-storage/async-storage: 1.18.2 => 1.18.2 
    @react-native-community/netinfo: 9.3.10 => 9.3.10 
    HelloWorld:  0.0.1 
    aws-amplify: ^6.0.10 => 6.0.10 
    aws-amplify/adapter-core:  undefined ()
    aws-amplify/analytics:  undefined ()
    aws-amplify/analytics/kinesis:  undefined ()
    aws-amplify/analytics/kinesis-firehose:  undefined ()
    aws-amplify/analytics/personalize:  undefined ()
    aws-amplify/analytics/pinpoint:  undefined ()
    aws-amplify/api:  undefined ()
    aws-amplify/api/server:  undefined ()
    aws-amplify/auth:  undefined ()
    aws-amplify/auth/cognito:  undefined ()
    aws-amplify/auth/cognito/server:  undefined ()
    aws-amplify/auth/enable-oauth-listener:  undefined ()
    aws-amplify/auth/server:  undefined ()
    aws-amplify/datastore:  undefined ()
    aws-amplify/in-app-messaging:  undefined ()
    aws-amplify/in-app-messaging/pinpoint:  undefined ()
    aws-amplify/push-notifications:  undefined ()
    aws-amplify/push-notifications/pinpoint:  undefined ()
    aws-amplify/storage:  undefined ()
    aws-amplify/storage/s3:  undefined ()
    aws-amplify/storage/s3/server:  undefined ()
    aws-amplify/storage/server:  undefined ()
    aws-amplify/utils:  undefined ()
    expo: ~49.0.15 => 49.0.21 
    expo-status-bar: ~1.6.0 => 1.6.0 
    react: 18.2.0 => 18.2.0 
    react-native: 0.72.6 => 0.72.6 
    react-native-get-random-values: ~1.9.0 => 1.9.0 
    react-native-sqlite-storage: ^6.0.1 => 6.0.1 
  npmGlobalPackages:
    corepack: 0.22.0
    ignite-cli: 9.2.0
    npm: 10.2.3
    yarn: 1.22.21

Describe the bug

Using a newly generated application, following the Datastore web guide the app fails to load the bundle with a missing reference to the library aws-amplify-datastore-sqlite-adapter-expo

Looking in the directory mentioned, ./node_modules/@aws-amplify/datastore-storage-adapter/dist/ I don't see the the expected file, aws-amplify-datastore-sqlite-adapter-expo[.min].js, but I do see them in datastore-storage-adapter/dist/umd. Changing the require string to umd at least stops the error, and allows the app to load, but I haven't tried using the datastore service yet.

Expected behavior

The application to successfully load in Expo Go.

Reproduction steps

  1. Run commands as per guide, and load app in emulator
npx create-expo-app AmplifyDataStoreExpo
cd AmplifyDataStoreExpo
expo install aws-amplify @aws-amplify/react-native @react-native-community/netinfo @aws-amplify/datastore-storage-adapter react-native-sqlite-storage @react-native-async-storage/async-storage react-native-get-random-values
yarn ios
  1. Add code to App.js
import { DataStore } from 'aws-amplify/datastore';
import { ExpoSQLiteAdapter } from '@aws-amplify/datastore-storage-adapter/ExpoSQLiteAdapter';

DataStore.configure({
  storageAdapter: ExpoSQLiteAdapter
});
  1. Reload app in Expo Go
  2. Receive error seen in log output

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line
 ERROR  [Error: undefined Unable to resolve module ../dist/aws-amplify-datastore-sqlite-adapter-expo.min.js from /XXX/AmplifyDataStoreExpo/node_modules/@aws-amplify/datastore-storage-adapter/ExpoSQLiteAdapter/index.js: 

None of these files exist:
  * node_modules/@aws-amplify/datastore-storage-adapter/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs)
  * node_modules/@aws-amplify/datastore-storage-adapter/dist/aws-amplify-datastore-sqlite-adapter-expo.min.js/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.cjs|.native.cjs|.cjs)
  4 |
  5 | if (process.env.NODE_ENV === 'production') {
> 6 | 	module.exports = require('../dist/aws-amplify-datastore-sqlite-adapter-expo.min.js');
    | 	                          ^
  7 | } else {
  8 | 	module.exports = require('../dist/aws-amplify-datastore-sqlite-adapter-expo.js');
  9 | }]


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

iPhone14 Emulator

Mobile Operating System

iOS16.4

Mobile Browser

Expo Go

Mobile Browser Version

No response

Additional information and screenshots

No response

@myfoostrong myfoostrong added the pending-triage Issue is pending triage label Jan 5, 2024
@cwomack cwomack added the DataStore Related to DataStore category label Jan 5, 2024
@chrisbonifacio chrisbonifacio self-assigned this Jan 8, 2024
@chrisbonifacio chrisbonifacio added to-be-reproduced Used in order for Amplify to reproduce said issue investigating This issue is being investigated and removed pending-triage Issue is pending triage labels Jan 8, 2024
@danrivett
Copy link

I can confirm we've also run into this exact same error, and so have temporarily removed using that adapter in our internal testing of our v5 -> v6 migration.

Would love to switch back to the Sqlite adapter soon as I believe query performance in particular is much better in an RN app.

@Oyetayo
Copy link

Oyetayo commented Jan 10, 2024

Experiencing the same issue. After several version tests, only version 2.0.30 seems to work
. All others are in this Path: datastore-storage-adapter/dist/umd not datastore-storage-adapter/dist/ and when you manually change it, it fails when you they to build the app.

@myfoostrong
Copy link
Author

Experiencing the same issue. After several version tests, only version 2.0.30 seems to work . All others are in this Path: datastore-storage-adapter/dist/umd not datastore-storage-adapter/dist/ and when you manually change it, it fails when you they to build the app.

This worked for me as well, both in a fresh Expo app as well as my exisiting app

@Oyetayo
Copy link

Oyetayo commented Jan 11, 2024

Experiencing the same issue. After several version tests, only version 2.0.30 seems to work. All others are in this Path: datastore-storage-adapter/dist/umd not datastore-storage-adapter/dist/ and when you manually change it, it fails when you they to build the app.

This worked for me as well, both in a fresh Expo app as well as my existing app

Yeah, but I don't think it is efficient, as my app still loads from the cloud directly and takes time to process queries. This looks more like an indication that the offline functionality of datastore is not working. I've been sweating my ass for days now looking for a workaround.

@david-mcafee david-mcafee self-assigned this Jan 11, 2024
@Oyetayo
Copy link

Oyetayo commented Jan 13, 2024

@david-mcafee pls can you help me out with this:
I've been encountering slow query performance in my app's AWS Amplify DataStore since it started getting more usage. Despite my efforts to troubleshoot, I haven't been able to find a solution. I suspect that the performance degradation might be linked to the aws-amplify-datastore-sqlite-adapter-expo. Here are the dependencies I'm currently using:

"@aws-amplify/datastore-storage-adapter": "^2.0.30",
"@react-native-async-storage/async-storage": "1.17.11",
"aws-amplify": "^5.3.14",
"expo": "~48.0.15",

The aws-amplify/datastore-storage-adapter vision I'm using is old and this is because of the path wrong i get when i run the more recent versions as started below.

Thanks in anticipation of your response.

@chrisbonifacio
Copy link
Contributor

Hi @myfoostrong 👋 thanks for raising this issue. I think I've run into this recently as well. Have you tried running npx expo run:ios instead?

@Oyetayo
Copy link

Oyetayo commented Jan 18, 2024

Hi @chrisbonifacio, the problem I see with this is that even if it is resolved with npx expo run: ios to run on the simulator, when you run eas build one would encounter the same issue there.

@danrivett
Copy link

In addition to fixing this broken import, Expo has just released SDK 50 which introduces a big update to their sqlite capability (see their release notes here).

I don't want to muddy the waters with this ticket, but other than say I hope DataStore supports sqlite well on Expo platforms for a long time and that the above Expo change helps this over time.

Looking forward to updates to this ticket with a fix.

@Makatun
Copy link

Makatun commented Jan 24, 2024

Same issue

@jgo80
Copy link

jgo80 commented Jan 27, 2024

Same issue using Expo 50

@raihanNoman
Copy link

tl;dr : It's a file path issue. Idk how to contact aws team. help!

Follow this file path:
node-modules > @aws-amplify > dtatastore-storage-adapter > ExpoSQLiteAdapter > index.js

The file contains:

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
'use strict';

if (process.env.NODE_ENV === 'production') {
	module.exports = require('../dist/aws-amplify-datastore-sqlite-adapter-expo.min.js');
} else {
	module.exports = require('../dist/aws-amplify-datastore-sqlite-adapter-expo.js');
}

Currently, the folder arrangement looks like this:
"@aws-amplify/datastore-storage-adapter": "^2.1.13" -Latest version

Screenshot 2024-01-31 at 10 06 13 PM

In one of my older projects 3 months ago , the folder arrangement looked like this:
"@aws-amplify/datastore-storage-adapter": "^2.0.40"

Screenshot 2024-01-31 at 10 04 47 PM

Help me contact AWS Team to change the modile.exports to the correct file path.

@raihanNoman
Copy link

Temporary Fix:

npm install @aws-amplify/datastore-storage-adapter@2.0.40

@jgo80
Copy link

jgo80 commented Feb 2, 2024

I think it's obvious and super simple to reproduce this error, what can we do to speed up this issue and tag it as a bug?

@chrisbonifacio chrisbonifacio added bug Something isn't working and removed investigating This issue is being investigated to-be-reproduced Used in order for Amplify to reproduce said issue labels Feb 2, 2024
@chrisbonifacio
Copy link
Contributor

chrisbonifacio commented Feb 2, 2024

Apologies for the delay. We're able to reproduce this internally.

Here's a minimum repro app for the team:
https://github.com/chrisbonifacio/amplify-expo-app

In the meantime, please use @aws-amplify/datastore-storage-adapter@2.0.40. Not sure if necessary, might just be something I did wrong, but I also had to install expo-sqlite alongside it to work.

I kept getting requireNativeModule ExpoSQLite errors otherwise.

@0nei
Copy link

0nei commented Feb 2, 2024

Apologies for the delay. We're able to reproduce this internally.

Here's a minimum repro app for the team: https://github.com/chrisbonifacio/amplify-expo-app

In the meantime, please use @aws-amplify/datastore-storage-adapter@2.0.40. Not sure if necessary, might just be something I did wrong, but I also had to install expo-sqlite alongside it to work.

I kept getting requireNativeModule ExpoSQLite errors otherwise.

Same, I also had to make sure expo-sqlite was installed for it to work, but otherwise using DataStore in my app appears to be working just fine with this temporary fix.

@amitchaudhary140
Copy link

@aws-amplify/datastore-storage-adapter@2.0.40

@chrisbonifacio When do you (team) plan to fix the issue related to the path? Also, switching to 2.0.40 is worth in terms of performance?

@david-mcafee david-mcafee linked a pull request Mar 5, 2024 that will close this issue
4 tasks
@david-mcafee
Copy link
Member

david-mcafee commented Mar 5, 2024

I currently have a PR open to fix the broken subpaths, but I also wanted to note that Expo Go is currently not officially supported by Amplify V6. However, Expo and React Native CLI apps are supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DataStore Related to DataStore category
Projects
None yet
Development

Successfully merging a pull request may close this issue.