aws / aws/aws-appsync-community
Subscription events not necessarily delivered after getting start_ack
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
The AppSync WebSocket protocol is described here: https://docs.aws.amazon.com/appsync/latest/devguide/real-time-websocket-client.html
When the subscription is established, AppSync sends a `start_ack` message. This should indicate that the subscription is active and future events will be delivered via `data` events.
**It seems like this is not the case.** Even when a mutation is triggered strictly after receiving the `start_ack` the subscription event might not be delivered. **This makes subscription handling unreliable** as there is not way to know when a subscription is really established.
Sequence:
* connect to WebSocket
* send `connection_init`
* wait for `connection_ack`
* send `start`
* wait for `start_ack`
* invoke a mutation
* wait for `data`
* close
Sometimes the `data` event does not arrive. Keeping a separate subscription (on the AppSync console, for example) shows that AppSync fired the event.
## Reproduction
There is a repository with the reproduction: https://github.com/sashee/appsync-start_ack
Follow the deploy/setup/run instructions from there.
## Observations
A successful run (notice the `data` event):
```
2025-12-13T11:08:43.732Z π§ͺ AppSync Subscription Event Loss Test
2025-12-13T11:08:43.737Z π Real-time endpoint: wss://e56qv7rp5nfq5jdpcjwlngii6m.appsync-realtime-api.eu-north-1.amazonaws.com/graphql
2025-12-13T11:08:43.737Z π GraphQL endpoint: https://e56qv7rp5nfq5jdpcjwlngii6m.appsync-api.eu-north-1.amazonaws.com/graphql
2025-12-13T11:08:43.737Z π API Key: da2-lr5qmb...
2025-12-13T11:08:43.737Z π Connecting to WebSocket...
2025-12-13T11:08:44.131Z π€ WebSocket connected
2025-12-13T11:08:44.131Z π€ Sending connection_init...
2025-12-13T11:08:44.205Z π₯ Received message: {"type":"connection_ack","payload":{"connectionTimeoutMs":300000}}
2025-12-13T11:08:44.205Z π₯ Received connection_ack
2025-12-13T11:08:44.206Z π€ Sending subscription start (ID: 70aed2a0-7e1c-47a4-86f1-74cbc1038289)...
2025-12-13T11:08:44.206Z π₯ Received message: {"type":"ka"}
2025-12-13T11:08:44.388Z π₯ Received message: {"id":"70aed2a0-7e1c-47a4-86f1-74cbc1038289","type":"start_ack"}
2025-12-13T11:08:44.389Z π₯ Received start_ack (ID: 70aed2a0-7e1c-47a4-86f1-74cbc1038289)
2025-12-13T11:08:44.389Z π€ Sending mutation with message: Test message - 1765624124389...
2025-12-13T11:08:44.640Z π₯ Mutation response: {"data":{"echoMessage":"Test message - 1765624124389"}}
2025-12-13T11:08:44.724Z π₯ Received message: {"id":"70aed2a0-7e1c-47a4-86f1-74cbc1038289","type":"data","payload":{"data":{"onEchoMessage":"Test message - 1765624124389"}}}
2025-12-13T11:08:44.724Z π₯ Received subscription event: {"data":{"onEchoMessage":"Test message - 1765624124389"}}
2025-12-13T11:08:44.814Z π₯ Received message: {"id":"70aed2a0-7e1c-47a4-86f1-74cbc1038289","type":"complete"}
2025-12-13T11:08:45.727Z β
Test completed successfully - event received
Exit code: 0
```
But sometimes the `data` event is missing:
```
2025-12-13T11:08:46.840Z π§ͺ AppSync Subscription Event Loss Test
2025-12-13T11:08:46.844Z π Real-time endpoint: wss://e56qv7rp5nfq5jdpcjwlngii6m.appsync-realtime-api.eu-north-1.amazonaws.com/graphql
2025-12-13T11:08:46.845Z π GraphQL endpoint: https://e56qv7rp5nfq5jdpcjwlngii6m.appsync-api.eu-north-1.amazonaws.com/graphql
2025-12-13T11:08:46.845Z π API Key: da2-lr5qmb...
2025-12-13T11:08:46.845Z π Connecting to WebSocket...
2025-12-13T11:08:47.265Z π€ WebSocket connected
2025-12-13T11:08:47.265Z π€ Sending connection_init...
2025-12-13T11:08:47.351Z π₯ Received message: {"type":"connection_ack","payload":{"connectionTimeoutMs":300000}}
2025-12-13T11:08:47.352Z π₯ Received connection_ack
2025-12-13T11:08:47.352Z π€ Sending subscription start (ID: 9fa7e46e-e5b5-4aa8-9a47-5551fcfde23f)...
2025-12-13T11:08:47.353Z π₯ Received message: {"type":"ka"}
2025-12-13T11:08:47.517Z π₯ Received message: {"id":"9fa7e46e-e5b5-4aa8-9a47-5551fcfde23f","type":"start_ack"}
2025-12-13T11:08:47.517Z π₯ Received start_ack (ID: 9fa7e46e-e5b5-4aa8-9a47-5551fcfde23f)
2025-12-13T11:08:47.517Z π€ Sending mutation with message: Test message - 1765624127517...
2025-12-13T11:08:47.799Z π₯ Mutation response: {"data":{"echoMessage":"Test message - 1765624127517"}}
2025-12-13T11:09:47.337Z π₯ Received message: {"type":"ka"}
```
A separate subscription shows that the event was indeed dispatched:
```
{
"data": {
"onEchoMessage": "Test message - 1765624127517"
}
}
```
Contributor guide
Research direction
Start with the AppSync real-time WebSocket protocol documentation and follow the deployment, setup, and run instructions in the linked appsync-start_ack reproduction repository. Compare successful and missing-data runs around start_ack, the mutation, and the data event. Done would require a confirmed explanation or reproducible resolution for events lost after start_ack.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100