diff --git a/.github/workflows/push-integ-test.yml b/.github/workflows/push-integ-test.yml index 03e43dd2865..9c6171a9ae4 100644 --- a/.github/workflows/push-integ-test.yml +++ b/.github/workflows/push-integ-test.yml @@ -8,7 +8,7 @@ concurrency: on: push: branches: - - replace-with-your-branch + - fix-events-close-all jobs: e2e: diff --git a/packages/api-graphql/src/Providers/AWSAppSyncEventsProvider/index.ts b/packages/api-graphql/src/Providers/AWSAppSyncEventsProvider/index.ts index 859f69fcde6..eff48289acc 100644 --- a/packages/api-graphql/src/Providers/AWSAppSyncEventsProvider/index.ts +++ b/packages/api-graphql/src/Providers/AWSAppSyncEventsProvider/index.ts @@ -53,27 +53,6 @@ export class AWSAppSyncEventProvider extends AWSWebSocketProvider { return PROVIDER_NAME; } - close() { - return new Promise((resolve, reject) => { - super.close(); - if (this.awsRealTimeSocket) { - this.awsRealTimeSocket.onclose = (_: CloseEvent) => { - this.subscriptionObserverMap = new Map(); - this.awsRealTimeSocket = undefined; - resolve(); - }; - - this.awsRealTimeSocket.onerror = (err: any) => { - reject(err); - }; - - this.awsRealTimeSocket.close(); - } else { - resolve(); - } - }); - } - public async connect(options: AWSAppSyncEventProviderOptions) { super.connect(options); } diff --git a/packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts b/packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts index 4a5e0d8f3b0..6d60e30316e 100644 --- a/packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts +++ b/packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts @@ -112,6 +112,24 @@ export abstract class AWSWebSocketProvider { this.connectionStateMonitorSubscription.unsubscribe(); // Complete all reconnect observers this.reconnectionMonitor.close(); + + return new Promise((resolve, reject) => { + if (this.awsRealTimeSocket) { + this.awsRealTimeSocket.onclose = (_: CloseEvent) => { + this.subscriptionObserverMap = new Map(); + this.awsRealTimeSocket = undefined; + resolve(); + }; + + this.awsRealTimeSocket.onerror = (err: any) => { + reject(err); + }; + + this.awsRealTimeSocket.close(); + } else { + resolve(); + } + }); } subscribe(