aws-appsync-subscription-link 2.2.6 → 2.2.7

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,18 @@
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="2.2.7"></a>
7
+ ## [2.2.7](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.5...aws-appsync-subscription-link@2.2.7) (2022-03-04)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * Port over Amplify fix for subscription race conditions for ApolloV2 ([#509](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/509)) ([#705](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/705)) ([f5022ba](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/f5022ba))
13
+ * **aws-appsync-subscription-link:** graphql header refactor to fix IAM-based auth for Apollo V2 packages ([#679](https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/679)) ([09fc430](https://github.com/awslabs/aws-mobile-appsync-sdk-js/commit/09fc430))
14
+
15
+
16
+
17
+
6
18
  <a name="2.2.6"></a>
7
19
  ## [2.2.6](https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/aws-appsync-subscription-link@2.2.5...aws-appsync-subscription-link@2.2.6) (2021-10-18)
8
20
 
@@ -22,7 +22,7 @@ export declare class AppSyncRealTimeSubscriptionHandshakeLink extends ApolloLink
22
22
  private _verifySubscriptionAlreadyStarted;
23
23
  private _sendUnsubscriptionMessage;
24
24
  private _removeSubscriptionObserver;
25
- private _closeSocketWhenFlushed;
25
+ private _closeSocketIfRequired;
26
26
  private _startSubscriptionWithAWSAppSyncRealTime;
27
27
  private _initializeWebSocketConnection;
28
28
  private _awsRealTimeHeaderBasedAuth;
@@ -221,22 +221,25 @@ var AppSyncRealTimeSubscriptionHandshakeLink = /** @class */ (function (_super)
221
221
  };
222
222
  AppSyncRealTimeSubscriptionHandshakeLink.prototype._removeSubscriptionObserver = function (subscriptionId) {
223
223
  this.subscriptionObserverMap.delete(subscriptionId);
224
- if (this.subscriptionObserverMap.size === 0) {
225
- // Socket could be sending data to unsubscribe so is required to wait until is flushed
226
- this._closeSocketWhenFlushed();
227
- }
224
+ // Verifying for 1000ms after removing subscription in case there are new subscriptions on mount / unmount
225
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
228
226
  };
229
- AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketWhenFlushed = function () {
230
- logger("closing WebSocket...");
231
- clearTimeout(this.keepAliveTimeoutId);
227
+ AppSyncRealTimeSubscriptionHandshakeLink.prototype._closeSocketIfRequired = function () {
228
+ if (this.subscriptionObserverMap.size > 0) {
229
+ // There are active subscriptions on the WebSocket
230
+ return;
231
+ }
232
232
  if (!this.awsRealTimeSocket) {
233
233
  this.socketStatus = types_1.SOCKET_STATUS.CLOSED;
234
234
  return;
235
235
  }
236
236
  if (this.awsRealTimeSocket.bufferedAmount > 0) {
237
- setTimeout(this._closeSocketWhenFlushed.bind(this), 1000);
237
+ // There is still data on the WebSocket
238
+ setTimeout(this._closeSocketIfRequired.bind(this), 1000);
238
239
  }
239
240
  else {
241
+ logger("closing WebSocket...");
242
+ clearTimeout(this.keepAliveTimeoutId);
240
243
  var tempSocket = this.awsRealTimeSocket;
241
244
  tempSocket.close(1000);
242
245
  this.awsRealTimeSocket = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aws-appsync-subscription-link",
3
- "version": "2.2.6",
3
+ "version": "2.2.7",
4
4
  "main": "lib/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "description": "AWS Mobile AppSync SDK for JavaScript",
@@ -23,7 +23,7 @@
23
23
  "apollo-link-context": "1.0.11",
24
24
  "apollo-link-http": "1.5.8",
25
25
  "apollo-link-retry": "2.2.7",
26
- "aws-appsync-auth-link": "^2.0.7",
26
+ "aws-appsync-auth-link": "^2.0.8",
27
27
  "debug": "2.6.9",
28
28
  "url": "^0.11.0"
29
29
  },