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.39k stars 2.11k forks source link

DataStore upgrading from 2.2.6 to 2.2.7+ breaks realtime data #6580

Closed mdoesburg closed 3 years ago

mdoesburg commented 3 years ago

Describe the bug After upgrading the DataStore from version 2.2.6 to 2.2.7, the following error is printed in the console right after the DataStore is ready:

[DEBUG] 46:46.527 AWSAppSyncRealTimeProvider - closing WebSocket...

DataStore version 2.2.7 introduces some bug fix I need:

This issue persists even in the latest DataStore version (2.2.9), and while having all the other Amplify packages up-to-date.

I have these packages installed:

Downgrading the DataStore version to 2.2.6 fixes this issue, but leaves me without the bug fixes.

Expected behavior I expect realtime data to keep working after upgrading to the latest version of the DataStore.

iartemiev commented 3 years ago

@mdoesburg just out of curiosity, have you tried creating a new cloud environment for your app?

amplify env add {new_name}
amplify push
amplify env checkout {new_name}

If that doesn't make a difference, you can always go back to the previous env and delete this one with:

amplify env checkout {previous_name}
amplify env remove {new_name}

I'm just wondering if maybe the error you're getting is the result of some combination of iterative changes to the schema... Obviously, that shouldn't be leading to errors, but I thought this might be worth trying anyways.

mdoesburg commented 3 years ago

@iartemiev I already had 2 environments, but tried making another one because you never know. :p Unfortunately it didn't fix anything, and I am getting the same subscription error and the websocket closes.

iartemiev commented 3 years ago

Got it. Thanks for trying that!

Does the shape of the schema in src/models/schema.js for User look the same in the sample app vs your app? What about the generated graphql schema in amplify/backend/api/app-name/build/schema.graphql?

mdoesburg commented 3 years ago

@iartemiev schema.js for User is an exact match, so is the type User in schema.graphql for both apps.

iartemiev commented 3 years ago

Are you getting the error for any signed-in user? Or just those that don't belong to the Admin group?

mdoesburg commented 3 years ago

@iartemiev Only users that don't belong to the Admin group get the error.

iartemiev commented 3 years ago

@mdoesburg, you're correct that if a single subscription fails, we currently close all subscriptions. We will be changing this behavior to allow other subscriptions to continue when this happens.

mdoesburg commented 3 years ago

We will be changing this behavior to allow other subscriptions to continue when this happens.

@iartemiev That would be nice! Any timeline on when this will be added?

vhuerta commented 3 years ago

This is happening to me as well (RN project) with the following schema:

type Config @model @auth(rules: [{ allow: owner, operations: [read, create, update] }]) {
  id: ID!
  conektaId: String
  paymentSources: AWSJSON
}

type Service @model @auth(rules: [{ allow: private, provider: userPools, operations: [read] }]) {
  id: ID!
  name: String!
  image: String!
  order: Int!
}

when I upgrade to:

@aws-amplify/datastore@2.2.7+

2.2.6 works fine

iartemiev commented 3 years ago

@mdoesburg we're currently reviewing a PR that fixes this, so it will be very soon

iartemiev commented 3 years ago

@mdoesburg just merged the PR, so please try with the latest unstable versions

mdoesburg commented 3 years ago

@iartemiev I can confirm that the websocket no longer closes on the latest unstable version.

iartemiev commented 3 years ago

Great! The changes will be included in the next stable release that'll go out in the very near future. Can we close this issue?

mdoesburg commented 3 years ago

@iartemiev Yes, go ahead and close it! Thanks again for your help, I really appreciate it! :)

iartemiev commented 3 years ago

Of course! Glad we were able to resolve this (:

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.