-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 max subscriptions reached error #7036
Comments
Tagging @iartemiev and @undefobj to get their attention. Thanks!! |
Here's an updated reproduction method and I've included a repo here.
|
@amhinson Were you guys able to consistently repro the issue with the repo I posted above? |
Yes, thanks for the great reproduction sample! 🙏 We are aware of the issue, particularly as it relates to other similar issues around subscriptions, and it is in our internal queue. |
Soo it's been almost 2 months after the last reply, I've been wondering is there any progress on this ticket? |
This is still being tracked for later this year. |
Is this a kind of fix that requires changes on the Appsync service? Or the client library needs some tweaking? From my observation is that we just need to make sure that the client's subscription is properly closed before initiating a new one. |
On macOS, I can't repro this issue with the app you provided, @nubpro. I've attempted to repro 2 different ways for step 4: A. Ethernet unplugged throughout the steps. Disable WiFi via the menu bar in step 4, enable in step 6 After going through the steps over a dozen times, I never experienced the error. DS always starts back up successfully without running into the max subs error. This is not to say that this error isn't happening, just that I can't reproduce it in my dev environment with your app/given steps. I have been able to inconsistently repro this error in the past with an RN app running on a physical iPhone specifically, so I'll go down that route again.
How would you do this from the client if the WebSocket connection is severed before it can be correctly closed? |
Pardon me for my lack of knowledge in this space, please do correct me if I'm wrong on the sequence and technical part (on step 8 especially).
The problem is at step 6, existing subscription A is not properly closed through websocket A. amplify-js/packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider.ts Lines 382 to 386 in 3719528
If I'm right about step 8, we should either reuse the same existing subscription for message 1 or to ensure it is properly closed by listening to GQL_COMPLETE . If it's not closed, just try to close it again. Repeat X times then back off.
I got most of this information by reading through this doc: Anyways, thanks for getting back @iartemiev, I'll try to reproduce the repo on my Mac and see it how it goes |
Alright, time for some update. On MacOS, I've tested my repo with the same reproduction steps on different browser, chrome and safari on the same Mac. Chrome v89: Meanwhile on Safari 14.0.2: Screen.Recording.2021-04-17.at.1.18.32.AM.mp4This is so odd, idk why they behave differently from one another, you can clearly see that Chrome on MacOS isnt logging any errors for some reason |
Thank you, @nubpro, I was also able to repro in Safari. Browsers can use different WebSocket libraries/implementations under the hood, so it's not completely unreasonable that they're behaving differently. Perhaps Chrome's implementation is more resilient around network connectivity loss. I'm going to dive deeper into this to make sure, but my understanding from reading the WebSocket Spec is that it's not possible to recover an improperly closed WebSocket connection. Attempting to reconnect, i.e., establishing a new subscription (step 9 in your comment) is likely the only way forward from the clientside. If so, the server (AppSync) would need to have a mechanism for closing these orphaned subscriptions sooner (AppSync currently disables subscriptions after 24 hours). |
any update on this? It's becoming a really big issue with content admin users. |
We're currently working on a solution to this issue with the AppSync team. Should be able to provide an update soon |
@nubpro after further testing, it appears that this is only reproducible with the steps you provided above if you call
Stopping DataStore at that point prevents it from cleaning up the socket connections correctly and when you call In other words, if you wait until you see those ^ logs (2-3 seconds) before calling I think we can do a better job of making sure the subscriptions are closed correctly even if stop/clear is called. However, unless someone is calling |
@vladimirzoyan could you please share how many models you have in your schema and exactly which steps/user actions lead to the "max subscriptions reached" error? |
We have deployed the app to more than 30 stores in production, and roughly 5 of them are suffering the same issue over and over again. No, we aren't calling DataStore.stop() at random. In fact, we don't at all. I see that you have posted a PR, does it totally address the underlying issue? |
It addresses the issue that occurs when following the repro steps. Since we've never been able to reproduce this any other way, I can't say definitively whether it will totally address every occurrence of this error for schemas containing up to 33 models. |
Welp, I really appreciate the effort for putting time into this. But damn, it took this long to get this issue prioritized. Part of it is because I wasn't able to provide clear steps but damn... |
We've released a fix for this in aws-amplify@4.0.3. Closing the issue. If you continue experiencing this issue after upgrading to the latest version of Amplify, please let us know and we will re-open it. |
I am experiencing this issue with latest react native and datastore. here's the error:
|
@rush86999 how many models do you have in your schema? |
69 models |
@rush86999 DataStore supports a maximum of 33 models, because it has to create 3 subscriptions per model to keep the local store in sync with AppSync. That error is expected for a schema containing > 33 models. |
can i turn off the subscriptions? I think there is a cost involved with keeping a connection open. Shouldn't this be optional? Also I realized mutations are not instant so for certain cases I would just use the regular API for direct mutations on dynamodb |
I just realized you mean my app will not work. Is there an alternative approach in this situation? I wish this was in the documentation someonwhere. I wrote my whole app already. I don't know where to go at this point. |
Can we turn off DataStore and call the API directly without issues? |
Hey @rush86999. |
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 |
Describe the bug
I found an easy and reliable method of reproducing "MaxSubscriptionsReachedError" error which is coming from AppSync. This is a React Native project.
To Reproduce
This is the most explicit ways I could figured out to reproduce the bug.
Updated repro methods:
#7036 (comment)
1. Setup Auth and DataStore on your app.2. Login and wait for syncing process is to finish. (I'd useHub.listen('datastore')
to wait forsyncQueriesReady
event to trigger)3. On your physical device, off the WiFi.4. Logout.5. Turn WiFi on.6. Repeat steps 2 to 6. Depends on your schema, you may need to do this up to 10 times until it hits the max subscription error. In my case, I would only need to repeat 5 times as my schema contains 7 models with 21 subscriptions.Expected behavior
Max subscription reached error shouldn't happen. When this happens, the app is unable to receive any incoming changes from the server anymore.
Code Snippet
I don't have any project samples that I can share at the moment.
Screenshots
Here's a screenshot of what I get.
Environment
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: