Skip to content

Commit

Permalink
fix: added check for observer (#736)
Browse files Browse the repository at this point in the history
Co-authored-by: Šimon Kvasnička <kvasnicka.simon@gmail.com>
  • Loading branch information
dpilch and simon-q authored Nov 16, 2022
1 parent 59be088 commit 758a55e
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,19 @@ export class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
});
clearTimeout(startAckTimeoutId);

observer.complete();
if (observer) {
observer.error({
errors: [
{
...new GraphQLError(`Connection failed: ${JSON.stringify(payload)}`)
}
]
});
observer.complete();
} else {
logger(`observer not found for id: ${id}`);
}

if (typeof subscriptionFailedCallback === "function") {
subscriptionFailedCallback();
}
Expand Down

0 comments on commit 758a55e

Please sign in to comment.