@graphql-tools/executor-http 1.2.4 → 1.2.5-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72

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
@@ -1,5 +1,19 @@
1
1
  # @graphql-tools/executor-http
2
2
 
3
+ ## 1.2.5-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72
4
+
5
+ ### Patch Changes
6
+
7
+ - [#407](https://github.com/graphql-hive/gateway/pull/407) [`31d44e7`](https://github.com/graphql-hive/gateway/commit/31d44e76d3e17b29527b4604440c39687a0880f5) Thanks [@ardatan](https://github.com/ardatan)! - Introduce disposable timeout signals.
8
+
9
+ When `AbortSignal.timeout(MS)` is used, the timer is not cleaned up until it finishes.
10
+ This leads to memory leaks when the signal is not used anymore.
11
+
12
+ This change introduces a disposable timeout signal that cleans up the timer when the signal is disposed, and in the plugins the signal is disposed whenever the operation is completed.
13
+
14
+ - Updated dependencies [[`d8dc77b`](https://github.com/graphql-hive/gateway/commit/d8dc77bc27e4abf917b03c197fe569c509e54a72), [`31d44e7`](https://github.com/graphql-hive/gateway/commit/31d44e76d3e17b29527b4604440c39687a0880f5)]:
15
+ - @graphql-hive/gateway-abort-signal-any@0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72
16
+
3
17
  ## 1.2.4
4
18
 
5
19
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -341,8 +341,10 @@ function buildHTTPExecutor(options) {
341
341
  }
342
342
  signals.push(signalFromRequest);
343
343
  }
344
+ let timeoutSignal;
344
345
  if (options?.timeout) {
345
- signals.push(AbortSignal.timeout(options.timeout));
346
+ timeoutSignal = gatewayAbortSignalAny.createTimeoutSignalWithDispose(options.timeout);
347
+ signals.push(timeoutSignal.signal);
346
348
  }
347
349
  const signal = gatewayAbortSignalAny.abortSignalAny(signals);
348
350
  const upstreamErrorExtensions = {
@@ -434,6 +436,7 @@ function buildHTTPExecutor(options) {
434
436
  }
435
437
  }
436
438
  }).then((fetchResult) => {
439
+ timeoutSignal?.[disposablestack.DisposableSymbols.dispose]();
437
440
  upstreamErrorExtensions.response ||= {};
438
441
  upstreamErrorExtensions.response.status = fetchResult.status;
439
442
  upstreamErrorExtensions.response.statusText = fetchResult.statusText;
@@ -510,6 +513,7 @@ function buildHTTPExecutor(options) {
510
513
  return result;
511
514
  }
512
515
  }).catch((e) => {
516
+ timeoutSignal?.[disposablestack.DisposableSymbols.dispose]();
513
517
  if (e.name === "AggregateError") {
514
518
  return {
515
519
  errors: e.errors.map(
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { abortSignalAny } from '@graphql-hive/gateway-abort-signal-any';
1
+ import { createTimeoutSignalWithDispose, abortSignalAny } from '@graphql-hive/gateway-abort-signal-any';
2
2
  import { defaultPrintFn, serializeExecutionRequest } from '@graphql-tools/executor-common';
3
3
  import { isAsyncIterable, isPromise, mapMaybePromise, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, memoize1, getOperationASTFromRequest } from '@graphql-tools/utils';
4
4
  import { DisposableSymbols } from '@whatwg-node/disposablestack';
@@ -339,8 +339,10 @@ function buildHTTPExecutor(options) {
339
339
  }
340
340
  signals.push(signalFromRequest);
341
341
  }
342
+ let timeoutSignal;
342
343
  if (options?.timeout) {
343
- signals.push(AbortSignal.timeout(options.timeout));
344
+ timeoutSignal = createTimeoutSignalWithDispose(options.timeout);
345
+ signals.push(timeoutSignal.signal);
344
346
  }
345
347
  const signal = abortSignalAny(signals);
346
348
  const upstreamErrorExtensions = {
@@ -432,6 +434,7 @@ function buildHTTPExecutor(options) {
432
434
  }
433
435
  }
434
436
  }).then((fetchResult) => {
437
+ timeoutSignal?.[DisposableSymbols.dispose]();
435
438
  upstreamErrorExtensions.response ||= {};
436
439
  upstreamErrorExtensions.response.status = fetchResult.status;
437
440
  upstreamErrorExtensions.response.statusText = fetchResult.statusText;
@@ -508,6 +511,7 @@ function buildHTTPExecutor(options) {
508
511
  return result;
509
512
  }
510
513
  }).catch((e) => {
514
+ timeoutSignal?.[DisposableSymbols.dispose]();
511
515
  if (e.name === "AggregateError") {
512
516
  return {
513
517
  errors: e.errors.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/executor-http",
3
- "version": "1.2.4",
3
+ "version": "1.2.5-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72",
4
4
  "type": "module",
5
5
  "description": "A set of utils for faster development of GraphQL tools",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@graphql-hive/gateway-abort-signal-any": "^0.0.3",
42
+ "@graphql-hive/gateway-abort-signal-any": "0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72",
43
43
  "@graphql-tools/executor-common": "^0.0.1",
44
44
  "@graphql-tools/utils": "^10.7.0",
45
45
  "@repeaterjs/repeater": "^3.0.4",