Skip to content

Commit 70c7cbb

Browse files
committed
Fix close() delay bug
1 parent 01fc7bc commit 70c7cbb

File tree

2 files changed

+6
-4
lines changed
  • packages/api-graphql/src

2 files changed

+6
-4
lines changed

packages/api-graphql/src/Providers/AWSAppSyncEventsProvider/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class AWSAppSyncEventProvider extends AWSWebSocketProvider {
7979
}
8080

8181
public closeIfNoActiveChannel() {
82-
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
82+
this._closeSocketIfRequired();
8383
}
8484

8585
protected async _prepareSubscriptionPayload({

packages/api-graphql/src/internals/events/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ async function connect(
101101
const close = async () => {
102102
_subscription && _subscription.unsubscribe();
103103
openChannels.delete(channelId);
104-
if (openChannels.size === 0) {
105-
eventProvider.closeIfNoActiveChannel();
106-
}
104+
setTimeout(() => {
105+
if (openChannels.size === 0) {
106+
eventProvider.closeIfNoActiveChannel();
107+
}
108+
}, 1000);
107109
};
108110

109111
return {

0 commit comments

Comments
 (0)