Skip to content

Commit

Permalink
fix(api-graphql): apply WS.close to base class
Browse files Browse the repository at this point in the history
  • Loading branch information
iartemiev committed Nov 6, 2024
1 parent 168ecff commit d26c3cc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/push-integ-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:
on:
push:
branches:
- replace-with-your-branch
- fix-events-close-all

jobs:
e2e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,6 @@ export class AWSAppSyncEventProvider extends AWSWebSocketProvider {
return PROVIDER_NAME;
}

close() {
return new Promise<void>((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);
}
Expand Down
18 changes: 18 additions & 0 deletions packages/api-graphql/src/Providers/AWSWebSocketProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ export abstract class AWSWebSocketProvider {
this.connectionStateMonitorSubscription.unsubscribe();
// Complete all reconnect observers
this.reconnectionMonitor.close();

return new Promise<void>((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(
Expand Down

0 comments on commit d26c3cc

Please sign in to comment.