@apollo/client 3.7.12 → 3.7.14

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/apollo-client.cjs CHANGED
@@ -1360,7 +1360,7 @@ var concat = ApolloLink.concat;
1360
1360
 
1361
1361
  var execute = ApolloLink.execute;
1362
1362
 
1363
- var version = '3.7.12';
1363
+ var version = '3.7.14';
1364
1364
 
1365
1365
  function isNodeResponse(value) {
1366
1366
  return !!value.body;
@@ -7233,9 +7233,13 @@ function useSubscription(subscription, options) {
7233
7233
  if (!observable) {
7234
7234
  return;
7235
7235
  }
7236
+ var subscriptionStopped = false;
7236
7237
  var subscription = observable.subscribe({
7237
7238
  next: function (fetchResult) {
7238
7239
  var _a, _b;
7240
+ if (subscriptionStopped) {
7241
+ return;
7242
+ }
7239
7243
  var result = {
7240
7244
  loading: false,
7241
7245
  data: fetchResult.data,
@@ -7258,26 +7262,33 @@ function useSubscription(subscription, options) {
7258
7262
  },
7259
7263
  error: function (error) {
7260
7264
  var _a, _b;
7261
- setResult({
7262
- loading: false,
7263
- data: void 0,
7264
- error: error,
7265
- variables: options === null || options === void 0 ? void 0 : options.variables,
7266
- });
7267
- (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
7265
+ if (!subscriptionStopped) {
7266
+ setResult({
7267
+ loading: false,
7268
+ data: void 0,
7269
+ error: error,
7270
+ variables: options === null || options === void 0 ? void 0 : options.variables,
7271
+ });
7272
+ (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
7273
+ }
7268
7274
  },
7269
7275
  complete: function () {
7270
7276
  var _a, _b;
7271
- if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
7272
- ref.current.options.onComplete();
7273
- }
7274
- else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
7275
- ref.current.options.onSubscriptionComplete();
7277
+ if (!subscriptionStopped) {
7278
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
7279
+ ref.current.options.onComplete();
7280
+ }
7281
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
7282
+ ref.current.options.onSubscriptionComplete();
7283
+ }
7276
7284
  }
7277
7285
  },
7278
7286
  });
7279
7287
  return function () {
7280
- subscription.unsubscribe();
7288
+ subscriptionStopped = true;
7289
+ setTimeout(function () {
7290
+ subscription.unsubscribe();
7291
+ });
7281
7292
  };
7282
7293
  }, [observable]);
7283
7294
  return result;