diff --git a/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts b/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts index bf91d897..c70a6937 100644 --- a/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts +++ b/packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts @@ -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(); }