Closed duranmla closed 1 year ago
Hi @duranmla 👋 thanks for raising this issue. Can you share your schema, or at least the models you believe might be part of the issue? I see you mentioned the flutter issue where they tested models with names such as Model{...}Connection
but you referenced a model called SkillParticipantConnection
which does not fit that format.
I noticed that you are establishing a listener in your signIn call, but are you also cleaning it up somewhere else? Perhaps on signOut? You may be experiencing this behavior because of duplicate/redundant listeners.
I have not been able to reproduce the issue with the steps given. I tried creating two models with a Connection
and Model{...}Connection
naming format, but neither resulted in the issue described in the Flutter repo.
schema
type Todo @model {
id: ID!
name: String!
description: String
}
type TodoConnection @model {
id: ID!
connected: Boolean
}
type ModelTodoConnection @model {
id: ID!
connected: Boolean
}
events
However, it's worth noting that the "ready" event was never emitted.
Upon checking the Amplify debugger logs, I can see that there are issues syncing the model named ModelTodoConnection
When inspecting the build schema, there is a manually created ModelTodoConnection
type as well as a CLI generated ModelModelTodoConnectionConnection
, which seems to be confusing the server and it expects to find the items
, nextToken
, and startedAt
fields on the manually created model rather than the CLI generated model.
Considering this, I'm going to label this a bug for the Data team to investigate further. Until we come back with feedback, I would assume that the Model{...}Connection
is reserved for the sync process and I would recommend avoiding it.
Hi @duranmla 👋 thanks for raising this issue. Can you share your schema, or at least the models you believe might be part of the issue? I see you mentioned the flutter issue where they tested models with names such as
Model{...}Connection
but you referenced a model calledSkillParticipantConnection
which does not fit that format.I noticed that you are establishing a listener in your signIn call, but are you also cleaning it up somewhere else? Perhaps on signOut? You may be experiencing this behavior because of duplicate/redundant listeners.
Hey, thanks for the reply, perhaps it is a problem with the duplicate/redundant listeners? I will take a look further once I finish some of the things I am doing, besides, I see also that you suggests that SkillParticipantConnection
does not match the format Model{...}Connection
, I though that when they said "Model" is any model name.
Either way, I have this issue on my app and another one with deployment that I need to come back later, I am just trying to move a little bit as much as I can while I got ideas from you folks.
Thanks a lot for the quick reply @chrisbonifacio
One thing to mention with the comment of "redundant/duplicated" listeners is that I have a signOut method on my service like so:
signOut: async (options?: Object) => {
await Auth.signOut(options)
await DataStore.clear()
dispatch(logOutUser())
analytics.trackEvent('LOGOUT')
analytics.reset()
},
But how that can affect if it is not being trigger until the user click logout?
I don't see that you are cleaning up the hub listener in either the sign in or sign out but you wouldn't accidentally set up more than one without signing in and out.
Can you share your schema? Or at least the models that seem to have this issue? You can also enable logging from Amplify by adding this line to your app:
Amplify.Logger.LOG_LEVEL = "DEBUG";
This should provide more insight into what's going on behind the scenes with DataStore, hopefully exposing some internal or network operations that are failing during the initial sync process.
Sure, the schema I currently have is this one. https://gist.github.com/duranmla/5318da2f405d5b9d6baf0dfe36e170bd
Also, I do have that logger level setup. Thanks for that anyway. I show the code at another issue I have at https://github.com/aws-amplify/amplify-js/issues/10382
UPDATE: I actually have INFO, I will change to DEBUG to check this out. Thanks for that.
🤔 I should maybe post that issue here tho.
Hey @duranmla are you still experiencing this issue or have you been able to resolve it as well?
If the issue persists, please share the CLI version and schema so we can reproduce this more accurately?
Transferring this issue over to the category-api repo because the return type for the sync query is not being computed correctly depending on the naming convention of a model that results in a naming collision during the sync
Hey @chrisbonifacio not at all, the problem I had was seems to be caused by the fact I was running the DataStore.config twice https://github.com/aws-amplify/amplify-js/issues/10382#issuecomment-1265872505 thanks to your help I was able to get rid of this one.
Sorry for the delay to answer. It seems I have missed some Github notifications.
@duranmla ah, no worries! Thanks for the update! I'll close this issue then and open a new one regarding the sync query error that results from naming models the same as a codegen type. I think we can improve the dev experience there.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
DataStore
Amplify Categories
No response
Environment information
Describe the bug
I have a service that on signIn, it logs the user and returns allowing some animations to happen while we wait for the DataStore 'ready' event to take place, for that I use the
Hub.listen('datastore', () => ...)
sadly, in the process I let the issue for later and now it is much more harder to understand when/which change make this stop working.Expected behavior
I should receive events when listen for "datastore" scope under the
Hub
Reproduction steps
I would imagine that by only trying to listen to
Hub.listen('datastore')
you might reproduce the issue but there is also https://github.com/aws-amplify/amplify-flutter/issues/1936#issuecomment-1252175413 that seems to claim on flutter they have a issue with models suffixed withConnection
which I have.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
I am using amplify 10.0.0