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

Return Error Status when attempting Datastore mutation, CognitoUserPools logged out state #645

Closed
wooj2 opened this issue Jul 15, 2020 · 4 comments
Labels
bug Something isn't working datastore Issues related to the DataStore category follow up Requires follow up from maintainers

Comments

@wooj2
Copy link
Contributor

wooj2 commented Jul 15, 2020

Is your feature request related to a problem? Please describe.
Originally reported here #395
There is a case if you configure an iOS app with the following:

  1. Authentication: cognito user pools
  2. Datastore w/ syncing capability via API
  3. A basic schema without @auth, for example, the one we have in our documentation:
type Post @model {
  id: ID!
  title: String!
  status: PostStatus!
  rating: Int
  content: String
}
enum PostStatus {
  DRAFT
  PUBLISHED
}

Given that when calling Amplify.Auth.fetchAuthSession returns false, attempt to make a mutation via Amplify.DataStore.save(), data is saved locally but fails to be synchronized to the backend.

Describe the solution you'd like
At a high level, the customer would like to know if something failed in the sync engine process, and perhaps if the mutation can never make it to the backend, then the mutation should not be stored locally, and an error should be presented to the user. This can be implemented in a variety of ways, but we have not done the work to come up with a design. Potential approaches to explore:

  • callback
  • hub notification
  • event on the publisher

Additional context

  • We will need to make sure that the behavior on iOS is also consistent on Android and JS.
@wooj2 wooj2 added the datastore Issues related to the DataStore category label Jul 15, 2020
@drochetti
Copy link
Contributor

At a high level, the customer would like to know if something failed in the sync engine process, and perhaps if the mutation can never make it to the backend

That expectation is correct and the DataStore configuration has an errorHandler that should be triggered in that scenario.

@wooj2
Copy link
Contributor Author

wooj2 commented Jul 16, 2020

@drochetti Great call out.

I tested a custom errorHandler and the errorHandler does get called, but the locally stored item doesn't seem to get sync'ed to the backend (even when you go back into an authenticated state and restart the sync engine). Looks like we'll need to dig into this.

@wooj2 wooj2 added bug Something isn't working follow up Requires follow up from maintainers labels Jul 17, 2020
@drochetti
Copy link
Contributor

@wooj2 @diegocstn is this one possibly related to the sync engine start/stop/restart logic being currently reviewed?

@diegocstn
Copy link
Contributor

diegocstn commented Jun 26, 2021

I believe with the current state of DataStore, per #815 and #1299, the sync engine should not halt in case of authentication errors and retry the mutation.

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 Issues related to the DataStore category follow up Requires follow up from maintainers
Projects
None yet
Development

No branches or pull requests

3 participants