aws-appsync-subscription-link 3.0.9 → 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
<a name="3.0.10"></a>
|
|
7
|
+
## [3.0.10](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.9...aws-appsync-subscription-link@3.0.10) (2022-03-04)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* Port over Amplify fix for subscription race conditions ([#509](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/509)) ([#704](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/704)) ([92b50c4](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/92b50c4))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
<a name="3.0.9"></a>
|
|
7
18
|
## [3.0.9](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@3.0.8...aws-appsync-subscription-link@3.0.9) (2021-09-24)
|
|
8
19
|
|
|
@@ -16,13 +16,11 @@ export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink
|
|
|
16
16
|
private subscriptionObserverMap;
|
|
17
17
|
private promiseArray;
|
|
18
18
|
constructor({ url: theUrl, region: theRegion, auth: theAuth }: UrlInfo);
|
|
19
|
-
request(operation: Operation): Observable<FetchResult<
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}, Record<string, any>, Record<string, any>>>;
|
|
19
|
+
request(operation: Operation): Observable<FetchResult<Record<string, any>, Record<string, any>, Record<string, any>>>;
|
|
22
20
|
private _verifySubscriptionAlreadyStarted;
|
|
23
21
|
private _sendUnsubscriptionMessage;
|
|
24
22
|
private _removeSubscriptionObserver;
|
|
25
|
-
private
|
|
23
|
+
private _closeSocketIfRequired;
|
|
26
24
|
private _startSubscriptionWithAWSAppSyncRealTime;
|
|
27
25
|
private _initializeWebSocketConnection;
|
|
28
26
|
private _awsRealTimeHeaderBasedAuth;
|
|
@@ -220,22 +220,25 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
|
|
|
220
220
|
};
|
|
221
221
|
AppSyncRealTimeSubscriptionHandshakeLink.prototype._removeSubscriptionObserver = function (subscriptionId) {
|
|
222
222
|
this.subscriptionObserverMap.delete(subscriptionId);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this._closeSocketWhenFlushed();
|
|
226
|
-
}
|
|
223
|
+
// Verifying for 1000ms after removing subscription in case there are new subscriptions on mount / unmount
|
|
224
|
+
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
|
|
227
225
|
};
|
|
228
|
-
AppSyncRealTimeSubscriptionHandshakeLink.prototype.
|
|
229
|
-
|
|
230
|
-
|
|
226
|
+
AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketIfRequired = function () {
|
|
227
|
+
if (this.subscriptionObserverMap.size > 0) {
|
|
228
|
+
// There are active subscriptions on the WebSocket
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
231
|
if (!this.awsRealTimeSocket) {
|
|
232
232
|
this.socketStatus = types_1.SOCKET_STATUS.CLOSED;
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
if (this.awsRealTimeSocket.bufferedAmount > 0) {
|
|
236
|
-
|
|
236
|
+
// There is still data on the WebSocket
|
|
237
|
+
setTimeout(this._closeSocketIfRequired.bind(this), 1000);
|
|
237
238
|
}
|
|
238
239
|
else {
|
|
240
|
+
logger("closing WebSocket...");
|
|
241
|
+
clearTimeout(this.keepAliveTimeoutId);
|
|
239
242
|
var tempSocket = this.awsRealTimeSocket;
|
|
240
243
|
tempSocket.close(1000);
|
|
241
244
|
this.awsRealTimeSocket = null;
|