aws / aws/aws-appsync-community

Subscription events not necessarily delivered after getting start_ack

Open
#405 2 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.