Closed ptero closed 2 years ago
This appears to be an issue with just Next.js. I'm looking into the root cause now.
Thanks
@dpilch would this be resolved by the commit from Jon here https://github.com/aws-amplify/amplify-js/pull/10055?
I was hitting some errors when testing with https://github.com/aws-amplify/amplify-js/pull/10055, but I think it may have been related to yarn link.
I know for certain that the one-liner change will fix this issue, but I will try testing with https://github.com/aws-amplify/amplify-js/pull/10055 again.
I tested again with https://github.com/aws-amplify/amplify-js/pull/10055 and it doesn't fix the error. The change in https://github.com/aws-amplify/amplify-js/pull/10234 is needed.
I encountered a similar problem using "await DataStore.clear()" and "await DataStore.clear()" during Authentication but I received different error message. I was using SvelteKit for frontend.
Hi @salmanprk, could you open another issue with the details of your error?
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
DataStore
Amplify Categories
api
Environment information
Describe the bug
Calling DataStore.clear() can create an unhandled runtime error: TypeError: Cannot read properties of undefined (reading 'close')
Call Stack IndexedDBAdapter.eval node_modules/@aws-amplify/datastore/lib-esm/storage/adapter/IndexedDBAdapter.js (1063:0) step node_modules/@aws-amplify/datastore/lib-esm/storage/adapter/IndexedDBAdapter.js (32:0) Object.eval [as next] node_modules/@aws-amplify/datastore/lib-esm/storage/adapter/IndexedDBAdapter.js (13:45) fulfilled node_modules/@aws-amplify/datastore/lib-esm/storage/adapter/IndexedDBAdapter.js (4:42)
This seems to occur when DataStore.clear() is called before the DataStore is ready or DataStore.start() is called.
Expected behavior
DataStore.clear() should be safe to call no matter its status. I am trying to implement best practice by calling DataStore.clear() based on signIn and signOut auth Hub events.
Reproduction steps
npx create-next-app@latest --typescript
npm i aws-amplify
amplify pull --appId d2kuwozgsh2xyn --envName dev
import awsconfig from "../src/aws-exports"; Amplify.configure(awsconfig);
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response