aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

undefined is not an object evaluating model[f] or model[f] #10508

Closed laclance closed 1 year ago

laclance commented 1 year ago

Before opening, please confirm:

JavaScript Framework

React, Next.js

Amplify APIs

DataStore

Amplify Categories

No response

Environment information

``` # Put output below this line System: OS: Windows 10 10.0.22621 CPU: (4) x64 Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz Memory: 3.05 GB / 7.84 GB Binaries: Node: 14.20.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD npm: 6.14.17 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.22621.674.0), Chromium (106.0.1370.47) Internet Explorer: 11.0.22621.1 npmPackages: @ampproject/toolbox-optimizer: undefined () @babel/core: undefined () @babel/helper-call-delegate: ^7.12.1 => 7.12.13 @babel/runtime: 7.15.4 @capacitor/core: ^4.3.0 => 4.3.0 @capacitor/device: ^4.0.1 => 4.0.1 @edge-runtime/primitives: 1.1.0-beta.31 @hapi/accept: undefined () @napi-rs/triples: undefined () @next/react-dev-overlay: undefined () @react-pdf/renderer: ^3.0.0 => 3.0.0 @segment/ajv-human-errors: undefined () @types/crypto-js: ^4.0.2 => 4.1.1 @types/intl-tel-input: ^17.0.5 => 17.0.5 @types/node: 18.11.0 => 18.11.0 (18.7.6) @types/qrcode.react: ^1.0.1 => 1.0.2 @types/react: ^18.0.21 => 18.0.21 @types/react-datepicker: ^4.4.1 => 4.4.2 @types/react-dom: ^18.0.6 => 18.0.6 @typescript-eslint/eslint-plugin: 5.40.1 => 5.40.1 @vercel/nft: undefined () @welldone-software/why-did-you-render: ^7.0.1 => 7.0.1 acorn: undefined () amphtml-validator: undefined () arg: undefined () array-move: ^4.0.0 => 4.0.0 assert: undefined () async-retry: undefined () async-sema: undefined () autoprefixer: ^10.4.12 => 10.4.12 aws-amplify: 4.3.39 => 4.3.39 babel-packages: undefined () browserify-zlib: undefined () browserslist: undefined () buffer: undefined () bytes: undefined () chalk: undefined () ci-info: undefined () cli-select: undefined () clsx: ^1.2.1 => 1.2.1 comment-json: undefined () compression: undefined () conf: undefined () constants-browserify: undefined () content-disposition: undefined () content-type: undefined () cookie: undefined () cross-spawn: undefined () crypto-browserify: undefined () crypto-js: ^4.1.1 => 4.1.1 cssnano-simple: undefined () debug: undefined () devalue: undefined () domain-browser: undefined () edge-runtime: undefined () eslint: 8.25.0 => 8.25.0 eslint-config-next: 12.3.1 => 12.3.1 eslint-config-prettier: ^8.5.0 => 8.5.0 events: undefined () find-cache-dir: undefined () find-up: undefined () fresh: undefined () get-orientation: undefined () glob: undefined () graphql-tag: ^2.12.6 => 2.12.6 gzip-size: undefined () http-proxy: undefined () https-browserify: undefined () husky: ^8.0.1 => 8.0.1 i18next: ^21.10.0 => 21.10.0 i18next-locize-backend: ^5.1.4 => 5.1.4 icss-utils: undefined () ignore-loader: undefined () image-size: undefined () intl-tel-input: ^17.0.19 => 17.0.19 is-animated: undefined () is-docker: undefined () is-wsl: undefined () jest-worker: undefined () json5: undefined () jsonwebtoken: undefined () ksuid: ^3.0.0 => 3.0.0 lint-staged: ^13.0.3 => 13.0.3 loader-utils: undefined () locize-cli: ^7.12.7 => 7.12.7 lodash.curry: undefined () lru-cache: undefined () micromatch: undefined () mini-css-extract-plugin: undefined () nanoid: undefined () native-url: undefined () neo-async: undefined () next: ^12.3.1 => 12.3.1 next-pwa: ^5.6.0 => 5.6.0 node-fetch: undefined () node-html-parser: undefined () ora: undefined () os-browserify: undefined () p-limit: undefined () path-browserify: undefined () postcss: ^8.4.18 => 8.4.18 (8.4.14, 7.0.39) postcss-flexbugs-fixes: undefined () postcss-modules-extract-imports: undefined () postcss-modules-local-by-default: undefined () postcss-modules-scope: undefined () postcss-modules-values: undefined () postcss-preset-env: undefined () postcss-safe-parser: undefined () postcss-scss: undefined () postcss-value-parser: undefined () prettier: ^2.6.1 => 2.7.1 process: undefined () punycode: undefined () qrcode.react: ^3.1.0 => 3.1.0 querystring-es3: undefined () raw-body: undefined () react: 18.2.0 => 18.2.0 react-datepicker: ^4.7.0 => 4.8.0 react-dnd: ^16.0.1 => 16.0.1 react-dnd-html5-backend: ^16.0.1 => 16.0.1 react-dom: 18.2.0 => 18.2.0 react-google-charts: ^4.0.0 => 4.0.0 react-i18next: ^11.18.6 => 11.18.6 react-indiana-drag-scroll: ^2.1.0 => 2.2.0 react-is: 17.0.2 react-loader-spinner: ^6.0.0-0 => 6.0.0-0 react-refresh: 0.12.0 react-scripts: 5.0.1 => 5.0.1 react-server-dom-webpack: undefined () react-simple-keyboard: ^3.4.226 => 3.4.226 regenerator-runtime: 0.13.4 sass-loader: undefined () schema-utils: undefined () semver: undefined () send: undefined () setimmediate: undefined () sharp: ^0.31.1 => 0.31.1 source-map: undefined () stream-browserify: undefined () stream-http: undefined () string-hash: undefined () string_decoder: undefined () strip-ansi: undefined () stylelint: ^14.14.0 => 14.14.0 stylelint-config-prettier: ^9.0.3 => 9.0.3 stylelint-config-standard: ^29.0.0 => 29.0.0 stylelint-config-tailwindcss: ^0.0.6 => 0.0.6 tailwindcss: ^3.1.8 => 3.1.8 tar: undefined () terser: undefined () text-table: undefined () timers-browserify: undefined () tty-browserify: undefined () typescript: 4.8.4 => 4.8.4 ua-parser-js: undefined () unistore: undefined () universal-cookie: ^4.0.4 => 4.0.4 util: undefined () vm-browserify: undefined () watchpack: undefined () web-vitals: undefined () webpack: undefined () webpack-sources: undefined () ws: undefined () npmGlobalPackages: @aws-amplify/cli: 10.3.0 npm: 6.14.17 yarn: 1.22.19 ```

Describe the bug

Been running datastore fine on desktop for about 2 years now but when calling DataStore.start() on a mobile device I get 2 errors.

undefined is not an object evaluating model[f] 
undefined is not an object evaluating model[field] 

Sometimes everything works fine and also sometimes I get no error but after syncQueriesStarted event gets fired nothing happens afterwards, modelSynced event does not fire.

Expected behavior

Should run the same as on a desktop.

Reproduction steps

run DataStore.start()

Code Snippet

// Put your code below this line.
import { Amplify, DataStore, syncExpression } from 'aws-amplify';
import aws_exports from '../aws-exports';

Amplify.configure({ ...aws_exports, ssr: true });

if (typeof window !== 'undefined') {
  DataStore.configure({
    syncExpressions: [
      syncExpression(TallorderPos, () => {
        const { id, sellingLocationID } = JSON.parse(window.localStorage.getItem('MerchantState') || '{}');
        alert(JSON.stringify({ id, sellingLocationID }));
        return c => c.pk('eq', sellingLocationID?.length ? `merchant#${id}#location#${sellingLocationID}` : 'null');
      }) as any
    ]
  });
}

await DataStore.clear().then(DataStore.start);

Log output

``` // Put your logs below this line IOS (SAFARI): [DEBUG] 17:57.990 DataStore - Starting DataStore [DEBUG] 17:57.993 DataStore - Starting Storage [DEBUG] 17:58.197 DataStore - GraphQL endpoint availablehttps://wv7yszmb7raffeedxhyxyba3ky.appsync-api.eu-west-1.amazonaws.com/graphql [INFO] 17:58.204 DataStore - starting sync engine... Navigated to http://192.168.43.3:3000/login/ [DEBUG] 17:58.335 Hub - Dispatching to datastore with Object {event: "storageSubscribed"} [DEBUG] 17:58.336 Hub - Dispatching to datastore with Object {event: "storageSubscribed"} [DEBUG] 17:58.338 Hub - Dispatching to datastore with Object {event: "networkStatus", data: Object} [DEBUG] 17:58.339 Hub - Dispatching to datastore with Object {event: "networkStatus", data: Object} [DEBUG] 17:58.341 AuthClass - getting current credentials [DEBUG] 17:58.341 Credentials - getting credentials [DEBUG] 17:58.341 Credentials - picking up credentials [DEBUG] 17:58.341 Credentials - getting new cred promise [DEBUG] 17:58.342 Credentials - checking if credentials exists and not expired Uncaught (in promise): DOMException: A mutation operation in a transaction failed because a constraint was not satisfied. Uncaught (in promise): DOMException: AbortError Uncaught TypeError: undefined is not an object (evaluating 'model[f]') undefined is not an object (evaluating 'model[f]') ``` ANDROID(CHROME): After getting and closing `Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing` 2nd attempt worked. ``` [DEBUG] 26:25.397 AWSAppSyncRealTimeProvider - Authenticating with API_KEY [DEBUG] 26:25.401 DataStore - Attempting Update subscription with authMode: API_KEY [DEBUG] 26:25.404 PubSub - subscribe optionsObject {provider: "[object Symbol]", appSyncGraphqlEndpoint: "https://wv7yszmb7raffeedxhyxyba3ky.appsync-api.…", authenticationType: "API_KEY"} [DEBUG] 26:25.407 AWSAppSyncRealTimeProvider - Authenticating with API_KEY [DEBUG] 26:25.410 DataStore - Attempting Delete subscription with authMode: API_KEY [DEBUG] 26:25.414 PubSub - subscribe optionsObject {provider: "[object Symbol]", appSyncGraphqlEndpoint: "https://wv7yszmb7raffeedxhyxyba3ky.appsync-api.…", authenticationType: "API_KEY"} [DEBUG] 26:25.417 AWSAppSyncRealTimeProvider - Authenticating with API_KEY [DEBUG] 26:25.420 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Disconnected"} [DEBUG] 26:25.422 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Disconnected"} [DEBUG] 26:25.423 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Disconnected"} [DEBUG] 26:25.425 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Disconnected"} [DEBUG] 26:25.432 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Disconnected"} [DEBUG] 26:25.434 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Disconnected"} [DEBUG] 26:25.439 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connecting"} [DEBUG] 26:25.441 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connecting"} [DEBUG] 26:25.443 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connecting"} [DEBUG] 26:25.444 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connecting"} [DEBUG] 26:25.445 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connecting"} [DEBUG] 26:25.447 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connecting"} [DEBUG] 26:27.176 AWSAppSyncRealTimeProvider - Notifying connection successful [DEBUG] 26:27.190 AWSAppSyncRealTimeProvider - subscription message from AWS AppSync RealTime: {"type":"ka"} [DEBUG] 26:27.192 AWSAppSyncRealTimeProviderObject {id: "", observer: null, query: "", variables: Object} [DEBUG] 26:27.541 AWSAppSyncRealTimeProvider - subscription message from AWS AppSync RealTime: {"id":"44e92b34-7dd8-4500-8549-8c0e43130081","type":"start_ack"} [DEBUG] 26:27.543 AWSAppSyncRealTimeProviderObject {id: "44e92b34-7dd8-4500-8549-8c0e43130081", observer: Object, query: "subscription operation { onDeleteTallorderPos…"} [DEBUG] 26:27.550 AWSAppSyncRealTimeProvider - subscription ready for {"query":"subscription operation {\n onDeleteTallorderPos {\n id\n pk\n sk\n entityType\n entityTag\n cu… [DEBUG] 26:27.553 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 26:27.556 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 26:27.558 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 26:27.559 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 26:27.563 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 26:27.565 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 26:27.566 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 26:27.568 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 26:27.570 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 26:27.572 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 26:27.573 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 26:27.574 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 26:27.588 AWSAppSyncRealTimeProvider - subscription message from AWS AppSync RealTime: {"id":"ee28bd53-fa2e-4d3c-a331-7a960937dfcb","type":"start_ack"} [DEBUG] 26:27.590 AWSAppSyncRealTimeProviderObject {id: "ee28bd53-fa2e-4d3c-a331-7a960937dfcb", observer: Object, query: "subscription operation { onUpdateTallorderSet…"} [DEBUG] 26:27.591 AWSAppSyncRealTimeProvider - subscription ready for {"query":"subscription operation {\n onUpdateTallorderSettings {\n id\n pk\n sk\n entityType\n entityTag\n … [DEBUG] 26:27.594 AWSAppSyncRealTimeProvider - subscription message from AWS AppSync RealTime: {"id":"1658aeee-cd2b-4a3f-a244-7f1f7a45f843","type":"start_ack"} ... DEBUG] 26:56.938 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.941 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.944 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.946 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.948 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.949 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.951 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.952 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.954 DataStore - params readyObject {modelConstructor: "[object Function]", predicate: Object, pagination: Object} [DEBUG] 26:56.966 DataStore - Starting Storage Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. [DEBUG] 27:12.158 AWSAppSyncRealTimeProvider - Authenticating with API_KEY [DEBUG] 27:12.173 AWSAppSyncRealTimeProvider - Initializaling retryable Handshake [DEBUG] 27:12.178 Util - bound attempt #1 with this vars: ["wss://wv7yszmb7raffeedxhyxyba3ky.appsync-realtime-api.eu-west-1.amazonaws.com/graphql?header=eyJob3N0Ijoid3Y3eXN6bWI3cmFmZmVlZHhoeXh… [DEBUG] 27:12.182 AWSAppSyncRealTimeProvider - Initializing handshake wss://wv7yszmb7raffeedxhyxyba3ky.appsync-realtime-api.eu-west-1.amazonaws.com/graphql?header=eyJob3N0Ijoid3Y3eXN6bWI3cmFmZm… [DEBUG] 27:12.298 Hub - Dispatching to datastore with Object {event: "outboxStatus", data: Object} [DEBUG] 27:12.299 Hub - Dispatching to datastore with Object {event: "outboxStatus", data: Object} [DEBUG] 27:12.468 Hub - Dispatching to datastore with Object {event: "syncQueriesStarted", data: Object} [DEBUG] 27:12.471 Hub - Dispatching to datastore with Object {event: "syncQueriesStarted", data: Object} [DEBUG] 27:12.479 DataStore - Attempting sync with authMode: API_KEY [DEBUG] 27:12.482 Util - attempt #1 with this vars: ["query operation($limit: Int, $nextToken: String, $lastSync: AWSTimestamp, $filter: ModelTallorderPosFilterInput){\n\t\tsyncTallorderPos(li… [DEBUG] 27:12.487 DataStore - Attempting sync with authMode: API_KEY [DEBUG] 27:12.488 Util - attempt #1 with this vars: ["query operation($limit: Int, $nextToken: String, $lastSync: AWSTimestamp, $filter: ModelTallorderSettingsFilterInput){\n\t\tsyncTallorderS… [DEBUG] 27:12.533 RestClient - POSThttps://wv7yszmb7raffeedxhyxyba3ky.appsync-api.eu-west-1.amazonaws.com/graphql [DEBUG] 27:13.907 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 27:13.910 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 27:13.912 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 27:13.917 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 27:13.919 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 27:13.921 Hub - Dispatching to api with Object {event: "Subscription ack", data: Object, message: "Connection established for subscription"} [DEBUG] 27:13.923 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 27:13.925 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 27:13.926 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 27:13.927 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 27:13.929 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 27:13.930 Hub - Dispatching to api with Object {event: "ConnectionStateChange", data: Object, message: "Connection state is Connected"} [DEBUG] 27:13.945 AWSAppSyncRealTimeProvider - subscription message from AWS AppSync RealTime: {"id":"fabc7c47-d3c8-47fa-a4aa-44a30677f9e4","type":"start_ack"} [DEBUG] 27:13.947 AWSAppSyncRealTimeProviderObject {id: "fabc7c47-d3c8-47fa-a4aa-44a30677f9e4", observer: Object, query: "subscription operation { onCreateTallorderPos…"} [DEBUG] 27:13.949 AWSAppSyncRealTimeProvider - subscription ready for {"query":"subscription operation {\n onCreateTallorderPos {\n id\n pk\n sk\n entityType\n entityTag\n cu… [DEBUG] 27:13.951 AWSAppSyncRealTimeProvider - subscription message from AWS AppSync RealTime: {"id":"e666d77f-8e13-4710-8515-34986edb0649","type":"start_ack"} [DEBUG] 27:13.952 AWSAppSyncRealTimeProviderObject {id: "e666d77f-8e13-4710-8515-34986edb0649", observer: Object, query: "subscription operation { onCreateTal... [DEBUG] 27:14.588 DataStore - Sync successful with authMode: API_KEY [DEBUG] 27:14.595 DataStore - Attempting sync with authMode: API_KEY [DEBUG] 27:14.598 Util - attempt #1 with this vars: ["query operation($limit: Int, $nextToken: String, $lastSync: AWSTimestamp, $filter: ModelTallorderSettingsFilterInput){\n\t\tsyncTallorderS… [DEBUG] 27:14.606 RestClient - POSThttps://wv7yszmb7raffeedxhyxyba3ky.appsync-api.eu-west-1.amazonaws.com/graphql [DEBUG] 27:15.148 DataStore - Sync successful with authMode: API_KEY [Fast Refresh] rebuilding [DEBUG] 27:15.702 DataStore - Sync successful with authMode: API_KEY [Fast Refresh] rebuilding [Fast Refresh] done in 231ms [DEBUG] 27:40.255 Hub - Dispatching to datastore with Object {event: "modelSynced", data: Object} [DEBUG] 27:40.257 Hub - Dispatching to datastore with Object {event: "modelSynced", data: Object} [DEBUG] 27:40.311 Hub - Dispatching to datastore with Object {event: "modelSynced", data: Object} [DEBUG] 27:40.315 Hub - Dispatching to datastore with Object {event: "modelSynced", data: Object} [DEBUG] 27:40.316 Hub - Dispatching to datastore with Object {event: "syncQueriesReady"} [DEBUG] 27:40.318 Hub - Dispatching to datastore with Object {event: "syncQueriesReady"} [DEBUG] 27:40.320 DataStore - Next fullSync in 86374.808 seconds. (Tue Oct 25 2022 14:27:15 GMT+0200 (Central Africa Time)) [DEBUG] 27:40.328 Hub - Dispatching to datastore with Object {event: "ready"} [DEBUG] 27:40.329 Hub - Dispatching to datastore with Object {event: "ready"} ```

aws-exports.js

const awsmobile = {
  aws_project_region: 'eu-west-1',
  aws_appsync_graphqlEndpoint: process.env.GRAPHQL_ENDPOINT,
  aws_appsync_region: 'eu-west-1',
  aws_appsync_authenticationType: 'API_KEY',
  aws_appsync_apiKey: process.env.AWS_API_KEY
};

export default awsmobile;

Manual configuration

No response

Additional configuration

No response

Mobile Device

2 iPhones and 2 Androids

Mobile Operating System

Old and new

Mobile Browser

brave, chrome and safari

Mobile Browser Version

No response

Additional information and screenshots

No response

laclance commented 1 year ago

maybe related https://github.com/aws-amplify/amplify-js/issues/6488

chrisbonifacio commented 1 year ago

Hey @laclance 👋 thanks for raising this issue. Could you please share your schema so that we can more closely reproduce this issue?

I noticed you're on the latest version of aws-amplify. The same day you posted this issue, another was opened regarding IndexedDB throwing the same AbortError on Safari. Please try downgrading to aws-amplify@4.3.37 or lower and let me know if the issue persists.

Thank you!

laclance commented 1 year ago
export const schema = {
    "models": {
        "TallorderPos": {
            "name": "TallorderPos",
            "fields": {
                "id": {
                    "name": "id",
                    "isArray": false,
                    "type": "ID",
                    "isRequired": true,
                    "attributes": []
                },
                "pk": {
                    "name": "pk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": true,
                    "attributes": []
                },
                "sk": {
                    "name": "sk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": true,
                    "attributes": []
                },
                "entityType": {
                    "name": "entityType",
                    "isArray": false,
                    "type": {
                        "enum": "EntityType"
                    },
                    "isRequired": true,
                    "attributes": []
                },
                "entityTag": {
                    "name": "entityTag",
                    "isArray": false,
                    "type": "String",
                    "isRequired": false,
                    "attributes": []
                },
                "currentState": {
                    "name": "currentState",
                    "isArray": false,
                    "type": {
                        "enum": "CurrentState"
                    },
                    "isRequired": true,
                    "attributes": []
                },
                "data": {
                    "name": "data",
                    "isArray": false,
                    "type": "AWSJSON",
                    "isRequired": false,
                    "attributes": []
                },
                "gsi1Pk": {
                    "name": "gsi1Pk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": false,
                    "attributes": []
                },
                "gsi1Sk": {
                    "name": "gsi1Sk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": false,
                    "attributes": []
                },
                "createdAt": {
                    "name": "createdAt",
                    "isArray": false,
                    "type": "AWSDateTime",
                    "isRequired": false,
                    "attributes": [],
                    "isReadOnly": true
                },
                "updatedAt": {
                    "name": "updatedAt",
                    "isArray": false,
                    "type": "AWSDateTime",
                    "isRequired": false,
                    "attributes": [],
                    "isReadOnly": true
                }
            },
            "syncable": true,
            "pluralName": "TallorderPos",
            "attributes": [
                {
                    "type": "model",
                    "properties": {}
                },
                {
                    "type": "key",
                    "properties": {
                        "name": "gsiPk-index",
                        "queryField": "GetTallorderPosByPk",
                        "fields": [
                            "pk",
                            "sk"
                        ]
                    }
                },
                {
                    "type": "key",
                    "properties": {
                        "name": "gsiEntity-index",
                        "queryField": "GetTallorderPosByEntityType",
                        "fields": [
                            "entityType",
                            "entityTag"
                        ]
                    }
                },
                {
                    "type": "key",
                    "properties": {
                        "name": "gsi1-index",
                        "queryField": "GetTallorderPosByGSI1",
                        "fields": [
                            "gsi1Pk",
                            "gsi1Sk"
                        ]
                    }
                },
                {
                    "type": "auth",
                    "properties": {
                        "rules": [
                            {
                                "allow": "public",
                                "operations": [
                                    "create",
                                    "update",
                                    "delete",
                                    "read"
                                ]
                            }
                        ]
                    }
                }
            ]
        },
        "TallorderSettings": {
            "name": "TallorderSettings",
            "fields": {
                "id": {
                    "name": "id",
                    "isArray": false,
                    "type": "ID",
                    "isRequired": true,
                    "attributes": []
                },
                "pk": {
                    "name": "pk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": true,
                    "attributes": []
                },
                "sk": {
                    "name": "sk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": true,
                    "attributes": []
                },
                "entityType": {
                    "name": "entityType",
                    "isArray": false,
                    "type": {
                        "enum": "EntityType"
                    },
                    "isRequired": true,
                    "attributes": []
                },
                "entityTag": {
                    "name": "entityTag",
                    "isArray": false,
                    "type": "String",
                    "isRequired": false,
                    "attributes": []
                },
                "currentState": {
                    "name": "currentState",
                    "isArray": false,
                    "type": {
                        "enum": "CurrentState"
                    },
                    "isRequired": true,
                    "attributes": []
                },
                "data": {
                    "name": "data",
                    "isArray": false,
                    "type": "AWSJSON",
                    "isRequired": false,
                    "attributes": []
                },
                "gsi1Pk": {
                    "name": "gsi1Pk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": false,
                    "attributes": []
                },
                "gsi1Sk": {
                    "name": "gsi1Sk",
                    "isArray": false,
                    "type": "String",
                    "isRequired": false,
                    "attributes": []
                },
                "createdAt": {
                    "name": "createdAt",
                    "isArray": false,
                    "type": "AWSDateTime",
                    "isRequired": false,
                    "attributes": [],
                    "isReadOnly": true
                },
                "updatedAt": {
                    "name": "updatedAt",
                    "isArray": false,
                    "type": "AWSDateTime",
                    "isRequired": false,
                    "attributes": [],
                    "isReadOnly": true
                }
            },
            "syncable": true,
            "pluralName": "TallorderSettings",
            "attributes": [
                {
                    "type": "model",
                    "properties": {}
                },
                {
                    "type": "key",
                    "properties": {
                        "name": "gsiPk-index",
                        "queryField": "GetTallorderSettingsByPk",
                        "fields": [
                            "pk",
                            "sk"
                        ]
                    }
                },
                {
                    "type": "key",
                    "properties": {
                        "name": "gsiEntity-index",
                        "queryField": "GetTallorderSettingsByEntityType",
                        "fields": [
                            "entityType",
                            "entityTag"
                        ]
                    }
                },
                {
                    "type": "key",
                    "properties": {
                        "name": "gsi1-index",
                        "queryField": "GetTallorderSettingsByGSI1",
                        "fields": [
                            "gsi1Pk",
                            "gsi1Sk"
                        ]
                    }
                },
                {
                    "type": "auth",
                    "properties": {
                        "rules": [
                            {
                                "allow": "public",
                                "operations": [
                                    "create",
                                    "update",
                                    "delete",
                                    "read"
                                ]
                            }
                        ]
                    }
                }
            ]
        }
    },
    "enums": {
        "EntityType": {
            "name": "EntityType",
            "values": [
                "CreditNote",
                "CreditNoteItem",
                "Customer",
                "CustomerAccount",
                "GlobalAppEnum",
                "GlobalSetting",
                "GlobalAccountSystem",
                "GlobalCountry",
                "GlobalCurrency",
                "GlobalLanguage",
                "GlobalPaymentType",
                "GlobalStockUnit",
                "GlobalTaxRegime",
                "AccountPayment",
                "LocationDepartment",
                "LocationDevice",
                "LocationItem",
                "LocationHeading",
                "LocationProduct",
                "LocationProductMedia",
                "LocationMedia",
                "LocationMenu",
                "LocationMenuHeading",
                "LocationMenuItem",
                "LocationMenuProduct",
                "LocationMenuTree",
                "LocationPaymentType",
                "LocationAddOn",
                "LocationAddOnGroup",
                "LocationProductAddOn",
                "LocationProductAddOnGroup",
                "LocationProductModifier",
                "LocationOption",
                "LocationOptionGroup",
                "LocationProductOption",
                "LocationProductOptionGroup",
                "LocationPortion",
                "LocationPortionGroup",
                "LocationProductPortion",
                "LocationProductPortionGroup",
                "LocationSetting",
                "LocationStaff",
                "LocationStockItem",
                "LocationStockAdjustment",
                "LocationStockUnit",
                "LocationStore",
                "LocationStoreApproval",
                "LocationStoreStockTake",
                "LocationStoreStockTakeItem",
                "LocationSupplier",
                "LocationStockTakeType",
                "LocationPayment",
                "LocationTaxGroup",
                "LocationTaxType",
                "LocationTag",
                "Merchant",
                "MerchantAudit",
                "MerchantDepartment",
                "MerchantDevice",
                "MerchantFolder",
                "MerchantGalleryState",
                "MerchantHeading",
                "MerchantProduct",
                "MerchantProductMedia",
                "MerchantMedia",
                "MerchantMenu",
                "MerchantMenuHeading",
                "MerchantMenuItem",
                "MerchantMenuProduct",
                "MerchantPaymentType",
                "MerchantAddOn",
                "MerchantAddOnGroup",
                "MerchantProductAddOn",
                "MerchantProductAddOnGroup",
                "MerchantProductModifier",
                "MerchantOption",
                "MerchantOptionGroup",
                "MerchantOrderApproval",
                "MerchantProductOption",
                "MerchantProductOptionGroup",
                "MerchantPortion",
                "MerchantPortionGroup",
                "MerchantProductPortion",
                "MerchantProductPortionGroup",
                "MerchantProductRecipe",
                "MerchantProductRecipeItem",
                "MerchantReport",
                "MerchantLocationReport",
                "MerchantStoreReport",
                "MerchantSellingLocation",
                "MerchantSetting",
                "MerchantStaff",
                "MerchantStaffAccess",
                "MerchantStaffApproval",
                "MerchantStockUnit",
                "MerchantStore",
                "MerchantSupplier",
                "MerchantStockTakeType",
                "MerchantTaxType",
                "MerchantTag",
                "MerchantUser",
                "Note",
                "POSPettyCash",
                "POSShift",
                "POSTab",
                "POSTabOrderLine",
                "POSTabPayment",
                "PurchaseOrder",
                "PurchaseOrderItem",
                "PurchaseOrderTemplate",
                "PurchaseOrderItemTemplate",
                "PendingPurchaseOrder",
                "PendingPurchaseOrderItem",
                "Refund",
                "StockAdjustment",
                "StockIssue",
                "StockIssueItem",
                "StockTake",
                "StockTakeItem",
                "StockRequisition",
                "StockRequisitionItem",
                "StockRequisitionTemplate",
                "StockRequisitionItemTemplate",
                "StockTransfer",
                "StockTransferItem",
                "StockTransferTemplate",
                "StockTransferItemTemplate",
                "SupplierReturn",
                "SupplierReturnItem"
            ]
        },
        "CurrentState": {
            "name": "CurrentState",
            "values": [
                "ACTIVE",
                "ADJUST",
                "ARCHIVED",
                "CLOSED",
                "COMPLETE",
                "DRAFT",
                "DRAFT_APPROVAL",
                "INACTIVE",
                "PLACED",
                "PLACED_APPROVAL",
                "PENDING",
                "OPEN",
                "RECEIVED",
                "REJECTED",
                "TEMPLATE"
            ]
        }
    },
    "nonModels": {},
    "version": "4767ca03090c2ef28d4487fb4cffd86c"
};
laclance commented 1 year ago

@chrisbonifacio thanks downgraded to aws-amplify@4.3.37 and it's working on safari.

laclance commented 1 year ago

on my android, which is much slower than my iphone i still get Uncaught (in promise): DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing but then after that datastore still syncs fine. Maybe also related to https://github.com/aws-amplify/amplify-js/issues/9282

laclance commented 1 year ago

Eventually to run into errors on safari:

Uncaught (in promise): TypeError: undefined is not an object (evaluating 'head.operation')
[WARN] 23:29.174 DataStore - subscriptionErrorConnection closed
Amplify errorObject {error: Object}
Amplify error
error: Object {recoverySuggestion: "Ensure app code is up to date, auth directives exist and are correct on each model, and that server-side data has not been invalidated by a schema change. If the problem persists, search for or create an issue: https://github.com/aws-amplify/amplify-js/issues", localModel: null, message: "Connection closed", model: "TallorderSettings", operation: "Delete", errorType: "Unknown", process: "subscribe", remoteModel: null, cause: Object} 
iartemiev commented 1 year ago

We just released a fix for DataStore in Safari browsers in aws-amplify@4.3.40. Please let us know if this resolves this issue as well.

laclance commented 1 year ago

Cannot find module '@aws-sdk/util-credentials'

iartemiev commented 1 year ago

@aws-sdk/util-credentials is not a dependency of Amplify and is not called from the library. Which platform are you experiencing this on? Can you share the stack trace for this error? What happens if you manually install this dependency into your application?

laclance commented 1 year ago

All platforms, as soon as I upgrade to 4.3.4*

Uncaught Error: Cannot find module '@aws-sdk/util-credentials'
Require stack:
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/resolveSsoCredentials.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/resolveProfileData.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/fromIni.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-node/dist-cjs/defaultProvider.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/client-sts/dist-cjs/runtimeConfig.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/client-sts/dist-cjs/STSClient.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/client-sts/dist-cjs/STS.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/client-sts/dist-cjs/index.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/dist-cjs/runtimeConfig.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/dist-cjs/LocationClient.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/dist-cjs/Location.js
- /home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/dist-cjs/index.js
- /home/lance/to-pos-nextjs/node_modules/@aws-amplify/geo/lib/Providers/AmazonLocationServiceProvider.js
- /home/lance/to-pos-nextjs/node_modules/@aws-amplify/geo/lib/Geo.js
- /home/lance/to-pos-nextjs/node_modules/@aws-amplify/geo/lib/index.js
- /home/lance/to-pos-nextjs/node_modules/aws-amplify/lib/index.js
- /home/lance/to-pos-nextjs/.next/server/pages/_app.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/server/require.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/server/next-server.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/server/dev/next-dev-server.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/server/next.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/server/lib/start-server.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/cli/next-dev.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/lib/commands.js
- /home/lance/to-pos-nextjs/node_modules/next/dist/bin/next
    at Function.Module._resolveFilename (:3000/internal/modules/cjs/loader.js:902:15)
    at Function.mod._resolveFilename (/home/lance/to-pos-nextjs/node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Function.Module._load (:3000/internal/modules/cjs/loader.js:746:27)
    at Module.require (:3000/internal/modules/cjs/loader.js:974:19)
    at require (:3000/internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/home/lance/to-pos-nextjs/node_modules/@aws-sdk/client-location/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js:7:28)
    at Module._compile (:3000/internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (:3000/internal/modules/cjs/loader.js:1114:10)
    at Module.load (:3000/internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (:3000/internal/modules/cjs/loader.js:790:12)
laclance commented 1 year ago

installing @aws-sdk/util-credentials removes the error and I am not getting any safari issues anymore.