Skip to content

Commit db8f9ae

Browse files
authored
fix: added check for observer (#735)
1 parent 0c6ddcb commit db8f9ae

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -755,16 +755,21 @@ export class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink {
755755
subscriptionState
756756
});
757757

758-
observer.error({
759-
errors: [
760-
{
761-
...new GraphQLError(`Connection failed: ${JSON.stringify(payload)}`)
762-
}
763-
]
764-
});
765758
clearTimeout(startAckTimeoutId);
766759

767-
observer.complete();
760+
if (observer) {
761+
observer.error({
762+
errors: [
763+
{
764+
...new GraphQLError(`Connection failed: ${JSON.stringify(payload)}`)
765+
}
766+
]
767+
});
768+
observer.complete();
769+
} else {
770+
logger(`observer not found for id: ${id}`);
771+
}
772+
768773
if (typeof subscriptionFailedCallback === "function") {
769774
subscriptionFailedCallback();
770775
}

0 commit comments

Comments
 (0)