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

DataStore does not expose errors on initial sync #7752

Closed
KyleBrost opened this issue Feb 15, 2021 · 8 comments
Closed

DataStore does not expose errors on initial sync #7752

KyleBrost opened this issue Feb 15, 2021 · 8 comments
Labels
DataStore Related to DataStore category feature-request Request a new feature

Comments

@KyleBrost
Copy link

Is your feature request related to a problem? Please describe.

When the DataStore does it's initial sync and there is an error on converting the data into Models there are silent errors raised. If you enable Amplify.Logger.LOG_LEVEL = 'DEBUG', you can see them on the console. Unfortunately there is no way to programmatically receive these errors and handle things gracefully.

Describe the solution you'd like
It would be great to have a listener function that could receive these errors so we could:

  1. Respond to the user with informative text
  2. Gracefully allow us to "ignore" the message and discard the offending records

Describe alternatives you've considered
The only option is to ensure the data model has no errors, which is ideal but then again we don't plan bad data. If we get bad data, it's a hard stop for the application as the DataStore does not fire the "ready" event.

Additional context
To reproduce:

  1. Create a simple model with no relationships, just an ID and a couple optional string fields
  2. Load some data
  3. Create an app that displays the data in a console after the DataStore has fired ready
  4. Change the data model to have another field "thisIsRequired: String!"
  5. Rebuild the app with the new model and try to fire it up

If you watch the network tab you will see the graphql query for the object failing because thisIsRequired cannot be null.

@KyleBrost KyleBrost added the feature-request Request a new feature label Feb 15, 2021
@amhinson
Copy link
Contributor

Have you considered using the errorHandler in the configuration object? This should notify you when these sync errors happen: https://docs.amplify.aws/lib/datastore/conflict/q/platform/js#custom-configuration

@amhinson amhinson added the DataStore Related to DataStore category label Feb 15, 2021
@KyleBrost
Copy link
Author

Have you considered using the errorHandler in the configuration object? This should notify you when these sync errors happen: https://docs.amplify.aws/lib/datastore/conflict/q/platform/js#custom-configuration

The errorHandler does not fire on the initial sync.

@amhinson
Copy link
Contributor

Ah interesting! I'd expect those errors to bubble up there. We can look into this 👍

@rraczae
Copy link

rraczae commented Feb 16, 2021

Hey team! Would it also be possible to add an event when a local migration is about to happen? That would be really super helpful in terms of migrating data especially for mobile apps.

I realize that the challenge here is we have to be aware of the last version the app was running, but at least we could create a local backup of the current data as json and re-sync manually for the time being.

Users working offline then the app updating in the background is a pretty common scenario.

Btw, appreciate the quick and thorough feedback on issues, it is really a great experience to work with the framework like this.

Rob

@amhinson
Copy link
Contributor

Hey @rraczae 👋 Would you be able to open up a new feature request for this? That will help our team better understand prioritization for any future improvements.

@rraczae
Copy link

rraczae commented Feb 16, 2021

@amhinson I think there is already a feature request for this actually: #7413
I added my comment here because migration came up as part of this convo on discord. Let me know if you'd still like a separate feature request. Cheers! Rob

@mtakac
Copy link

mtakac commented Mar 1, 2021

I ran into the same issue. It took me quite a while to realise what was wrong. Basically I had data in wrong format in my Dynamo DB and I never received the initial sync READY event. I have configured an error handler, but it didn't receive any errors.

@dpilch
Copy link
Member

dpilch commented Aug 9, 2022

This should be fixed by #9861. Please comment if you are still experiencing the issue.

@dpilch dpilch closed this as completed Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataStore Related to DataStore category feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

5 participants