amplify-js: Subscriptions sometimes fail, no error, no way to detect
Describe the bug We are seeing random fails when connecting to a subscription. There are no errors, looking at Chrome dev tools WS socket, it looks like the socket connects, but no data/messages are sent back.
The subscription is a standard subscription to GraphQL.
To Reproduce
I’m afraid this one is somewhat hard to reproduce. We are using the very latest version of amplify-js and the most recent changes to subscriptions in the library has not changed anything in relation to this.
I know this does not make it easy to debug on, but my hope is to get pointers on how to track any message sent back and use that to better understand when the socket fails. I have studied the source code and cannot find anything in there that was helpful (probably due to my lack of understanding the related code) but we do have error configured, though as mentioned, no error is thrown.
Maybe others have seen similar behavior?
Expected behavior That the library connects without issues and at least throws an error if it does not have a stable connection so that we can attempt to re-connect.
Update: I was able to catch messages sent in the console when this happened again.
- The client sends the GraphQL query to start the subscription.

- The client receives
start_ackand after that silence.
Nothing is changed in the code for things to break. The component is otherwise stable and this is just happening randomly once in n times. This happens across all our components and for multiple users. We feel like it was more stable in the past, but we can’t say as this is as mention hard to monitor on.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 4
- Comments: 15 (7 by maintainers)
Yeah, I will try it out.
If a subscription fails, there seems to be no real way of detecting that, even on errors. That means it’s hard on the UI side to detect a problem and attempt a reconnection.
I have also faced this issue. We use AppSync for realtime subscriptions with a custom Pipeline Authorizer Resolver. A subscription works fine, but when an error event is sent to the subscription (when creating the subscription), the SDK does not send it in the error callback of the subscription. Though the error is visible in network devtools for the socket.
Is there any progress on the issue? Right now, it isn’t possible to display a UI message when the subscription fails. 😕
Thank you. Hope to see that added soon, as sockets are really the basics of many web/native apps these days. I wonder why others don’t have problems with this.