diff --git a/packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider.ts b/packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider.ts index dbe610f12b2..d8e8095444a 100644 --- a/packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider.ts +++ b/packages/pubsub/src/Providers/AWSAppSyncRealTimeProvider.ts @@ -511,7 +511,7 @@ export class AWSAppSyncRealTimeProvider extends AbstractPubSubProvider { private _errorDisconnect(msg: string) { logger.debug(`Disconnect error: ${msg}`); this.subscriptionObserverMap.forEach(({ observer }) => { - if (!observer.closed) { + if (observer && !observer.closed) { observer.error({ errors: [{ ...new GraphQLError(msg) }], });