aws / aws/aws-appsync-community

Subscriptions not receiving updates after network disconnect/reconnect

Open
#80 1 comment 0 reactions 0 assignees View on GitHub
feature-request
Dominant language
HTML
Stars
507
Forks
37
PR merge metrics
No merged PRs in 30d

Description

Subscriptions do not receive updates anymore after a network disconnect/reconnect on a real device. On an emulator the subscription does receive updates after a network disconnect/reconnect.

I'm using react native with:

"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",

The code I'm using:

```
export function Cards(props) {

React.useEffect(() => {
subscribeToCardUpdates();
return () => {
if (Cards.unsubscribeCardUpdates) {
Cards.unsubscribeCardUpdates();
}
};
}, []);

const subscribeToCardUpdates = () => {
Cards.unsubscribeCardUpdates = props.subscribeToCardUpdates({
document: CardSubscriptionGraphQL,
variables: {
ownerId: 'someOwnerId',
},
onError: (error) => {
console.log(error);
trackEvent('Cards Subscription error', {error});
},
});
};

return (

);
}

export const mapCardsProps = (props) => {
return {
cards: props.data.cards.items,
subscribeToCardUpdates: props.data.subscribeToMore,
};
};

export default graphql(AccountAndCardsGraphQL, selectConfig(mapCardsProps))(Cards);
```
The subscription:

```
export const CardSubscriptionGraphQL = gql`
subscription CardSubscription($ownerId: String!) {
onCard(ownerId: $ownerId) {
id
ownerId
//Other properties...
}
}
`;
```

Contributor guide

Open the contributing guide

Research direction

Start with the Cards component, its subscribeToMore mapping, and the aws-appsync/react-native subscription setup shown in the report. Compare the real-device and emulator behavior across a network disconnect and reconnect, including the onError callback. Done means the GraphQL subscription resumes receiving updates on a real device after reconnection.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql, react-native
Domain
api, mobile, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.