@graphql-tools/executor-http
Advanced tools
Comparing version 1.2.5-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72 to 1.2.5-rc-be61b62d13f5f96c4571054aef4f218643b62afa
# @graphql-tools/executor-http | ||
## 1.2.5-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72 | ||
## 1.2.5-rc-be61b62d13f5f96c4571054aef4f218643b62afa | ||
### Patch Changes | ||
- [#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. | ||
- [#420](https://github.com/graphql-hive/gateway/pull/420) [`14152f7`](https://github.com/graphql-hive/gateway/commit/14152f70d91572c0e60ba15ddeb2ffd0b41c9e92) Thanks [@ardatan](https://github.com/ardatan)! - - In case of schema reload, throw `SCHEMA_RELOAD` error while recreating the transports and executors | ||
When `AbortSignal.timeout(MS)` is used, the timer is not cleaned up until it finishes. | ||
This leads to memory leaks when the signal is not used anymore. | ||
- In case of shut down, throw `SHUTTING_DOWN` error while cleaning the transports and executors up | ||
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. | ||
Previously, these errors are only thrown for subscriptions not it is thrown in other type of operations as well. | ||
And previously the thrown errors during these two cleanup and restart process were cryptic, now the mentioned two errors above are thrown with more clear messages | ||
- Updated dependencies [[`d8dc77b`](https://github.com/graphql-hive/gateway/commit/d8dc77bc27e4abf917b03c197fe569c509e54a72), [`31d44e7`](https://github.com/graphql-hive/gateway/commit/31d44e76d3e17b29527b4604440c39687a0880f5)]: | ||
- @graphql-hive/gateway-abort-signal-any@0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72 | ||
## 1.2.4 | ||
@@ -18,0 +15,0 @@ |
@@ -82,2 +82,6 @@ import { ExecutionRequest, DisposableSyncExecutor, DisposableAsyncExecutor } from '@graphql-tools/utils'; | ||
disposable?: boolean; | ||
/** | ||
* On dispose abort error | ||
*/ | ||
getDisposeReason?(): Error | undefined; | ||
} | ||
@@ -84,0 +88,0 @@ type HeadersConfig = Record<string, string>; |
@@ -1,2 +0,2 @@ | ||
import { createTimeoutSignalWithDispose, abortSignalAny } from '@graphql-hive/gateway-abort-signal-any'; | ||
import { abortSignalAny } from '@graphql-hive/gateway-abort-signal-any'; | ||
import { defaultPrintFn, serializeExecutionRequest } from '@graphql-tools/executor-common'; | ||
@@ -123,5 +123,2 @@ import { isAsyncIterable, isPromise, mapMaybePromise, createGraphQLError, inspect, mapAsyncIterator, mergeIncrementalResult, memoize1, getOperationASTFromRequest } from '@graphql-tools/utils'; | ||
function createAbortErrorReason() { | ||
return new Error("Executor was disposed."); | ||
} | ||
function createGraphQLErrorForAbort(reason, extensions) { | ||
@@ -133,7 +130,14 @@ if (reason instanceof GraphQLError) { | ||
return createGraphQLError(reason.message, { | ||
extensions, | ||
extensions: { | ||
http: { | ||
status: 504, | ||
...extensions?.["http"] || {} | ||
}, | ||
code: "TIMEOUT_ERROR", | ||
...extensions || {} | ||
}, | ||
originalError: reason | ||
}); | ||
} | ||
return createGraphQLError("The operation was aborted. reason: " + reason, { | ||
return createGraphQLError(reason.message, { | ||
extensions, | ||
@@ -184,3 +188,3 @@ originalError: reason | ||
if (signal?.aborted) { | ||
await push(createResultForAbort(signal)); | ||
await push(createResultForAbort(signal.reason)); | ||
return stop(); | ||
@@ -345,6 +349,4 @@ } | ||
} | ||
let timeoutSignal; | ||
if (options?.timeout) { | ||
timeoutSignal = createTimeoutSignalWithDispose(options.timeout); | ||
signals.push(timeoutSignal.signal); | ||
signals.push(AbortSignal.timeout(options.timeout)); | ||
} | ||
@@ -441,3 +443,2 @@ const signal = abortSignalAny(signals); | ||
}).then((fetchResult) => { | ||
timeoutSignal?.[DisposableSymbols.dispose](); | ||
upstreamErrorExtensions.response ||= {}; | ||
@@ -519,3 +520,2 @@ upstreamErrorExtensions.response.status = fetchResult.status; | ||
}).catch((e) => { | ||
timeoutSignal?.[DisposableSymbols.dispose](); | ||
if (e.name === "AggregateError") { | ||
@@ -593,3 +593,3 @@ return { | ||
return function dispose() { | ||
return disposeCtrl.abort(createAbortErrorReason()); | ||
return disposeCtrl.abort(options?.getDisposeReason?.()); | ||
}; | ||
@@ -601,3 +601,3 @@ } | ||
return function asyncDispose() { | ||
return disposeCtrl.abort(createAbortErrorReason()); | ||
return disposeCtrl.abort(options?.getDisposeReason?.()); | ||
}; | ||
@@ -604,0 +604,0 @@ } |
{ | ||
"name": "@graphql-tools/executor-http", | ||
"version": "1.2.5-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72", | ||
"version": "1.2.5-rc-be61b62d13f5f96c4571054aef4f218643b62afa", | ||
"type": "module", | ||
@@ -42,3 +42,3 @@ "description": "A set of utils for faster development of GraphQL tools", | ||
"dependencies": { | ||
"@graphql-hive/gateway-abort-signal-any": "0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72", | ||
"@graphql-hive/gateway-abort-signal-any": "^0.0.3", | ||
"@graphql-tools/executor-common": "^0.0.1", | ||
@@ -60,5 +60,5 @@ "@graphql-tools/utils": "^10.7.0", | ||
"graphql-yoga": "^5.10.6", | ||
"pkgroll": "2.6.0" | ||
"pkgroll": "2.6.1" | ||
}, | ||
"sideEffects": false | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1350
75820
+ Added@graphql-hive/gateway-abort-signal-any@0.0.3(transitive)
- Removed@graphql-hive/gateway-abort-signal-any@0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72(transitive)