New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-hive/gateway-abort-signal-any

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-hive/gateway-abort-signal-any - npm Package Compare versions

Comparing version 0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72 to 1.0.0-alpha-4105c094996f232c2b96db211bb33770260fcaef

21

CHANGELOG.md
# @graphql-hive/gateway-abort-signal-any
## 0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72
## 1.0.0-alpha-4105c094996f232c2b96db211bb33770260fcaef
### Patch Changes
### Major Changes
- [#407](https://github.com/graphql-hive/gateway/pull/407) [`d8dc77b`](https://github.com/graphql-hive/gateway/commit/d8dc77bc27e4abf917b03c197fe569c509e54a72) Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
- [#593](https://github.com/graphql-hive/gateway/pull/593) [`d6fbffa`](https://github.com/graphql-hive/gateway/commit/d6fbffa3533e2ab4005a589cc73e1806eaa73756) Thanks [@enisdenjo](https://github.com/enisdenjo)! - `abortSignalAny` uses `AbortSignal.any` if available and falls back to `AbortController` for ponyfilling
- Added dependency [`@whatwg-node/disposablestack@^0.0.5` ↗︎](https://www.npmjs.com/package/@whatwg-node/disposablestack/v/0.0.5) (to `dependencies`)
- [#593](https://github.com/graphql-hive/gateway/pull/593) [`d6fbffa`](https://github.com/graphql-hive/gateway/commit/d6fbffa3533e2ab4005a589cc73e1806eaa73756) Thanks [@enisdenjo](https://github.com/enisdenjo)! - `abortSignalAny` returns the native `AbortSignal`
- [#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.
Instead of the custom `AbortSignalFromAny`. There is no need for the complication of adding signals to existing sets, chaining signals enough as well as simpler.
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.
- [#593](https://github.com/graphql-hive/gateway/pull/593) [`d6fbffa`](https://github.com/graphql-hive/gateway/commit/d6fbffa3533e2ab4005a589cc73e1806eaa73756) Thanks [@enisdenjo](https://github.com/enisdenjo)! - `AbortSignal.any` ponyfill under `abortSignalAny` is now stable
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.
### Patch Changes
- [#593](https://github.com/graphql-hive/gateway/pull/593) [`6e8ff42`](https://github.com/graphql-hive/gateway/commit/6e8ff427a4360cdc8e822940b83d122f07659417) Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
- Removed dependency [`@graphql-tools/utils@^10.7.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/10.7.0) (from `dependencies`)
- Removed dependency [`tslib@^2.8.1` ↗︎](https://www.npmjs.com/package/tslib/v/2.8.1) (from `dependencies`)
- Removed dependency [`graphql@^15.0.0 || ^16.9.0 || ^17.0.0` ↗︎](https://www.npmjs.com/package/graphql/v/15.0.0) (from `peerDependencies`)
## 0.0.3

@@ -19,0 +24,0 @@

@@ -1,12 +0,3 @@

type AbortSignalFromAny = AbortSignal & {
signals: Set<AbortSignal>;
addSignals(signals: Iterable<AbortSignal>): void;
};
declare function isAbortSignalFromAny(signal?: AbortSignal | null): signal is AbortSignalFromAny;
declare function createTimeoutSignalWithDispose(timeout: number): {
signal: AbortSignal;
[Symbol.dispose](): void;
};
declare function abortSignalAny(givenSignals: Iterable<AbortSignal>): AbortSignal | undefined;
declare function abortSignalAny(iterable: Iterable<AbortSignal>): AbortSignal;
export { type AbortSignalFromAny, abortSignalAny, createTimeoutSignalWithDispose, isAbortSignalFromAny };
export { abortSignalAny };

@@ -1,78 +0,20 @@

import { registerAbortSignalListener } from '@graphql-tools/utils';
import { DisposableSymbols } from '@whatwg-node/disposablestack';
function isAbortSignalFromAny(signal) {
return signal != null && "signals" in signal && "addSignals" in signal;
}
function createTimeoutSignalWithDispose(timeout) {
function abortSignalAny(iterable) {
const signals = Array.from(iterable);
const aborted = signals.find((s) => s.aborted);
if (aborted) {
return aborted;
}
const ctrl = new AbortController();
const id = setTimeout(
() => ctrl.abort(
new DOMException(
"The operation was aborted due to timeout",
"TimeoutError"
)
),
timeout
);
return {
signal: ctrl.signal,
[DisposableSymbols.dispose]() {
clearTimeout(id);
function abort(event) {
ctrl.abort(event.target.reason);
for (const signal of signals) {
signal.removeEventListener("abort", abort);
}
};
}
function abortSignalAny(givenSignals) {
const signals = /* @__PURE__ */ new Set();
let singleSignal;
for (const signal of givenSignals) {
if (isAbortSignalFromAny(signal)) {
for (const childSignal of signal.signals) {
singleSignal = childSignal;
signals.add(childSignal);
}
} else {
singleSignal = signal;
signals.add(signal);
}
}
if (signals.size < 2) {
return singleSignal;
}
if (signals.size === 0) {
return void 0;
}
const ctrl = new AbortController();
function onAbort(ev) {
const signal = this || ev?.target;
ctrl.abort(signal?.reason);
}
for (const signal of signals) {
registerAbortSignalListener(signal, onAbort);
signal.addEventListener("abort", abort);
}
Object.defineProperties(ctrl.signal, {
signals: { value: signals },
addSignals: {
value(newSignals) {
for (const signal of newSignals) {
if (isAbortSignalFromAny(signal)) {
for (const childSignal of signal.signals) {
if (!signals.has(childSignal)) {
signals.add(childSignal);
registerAbortSignalListener(childSignal, onAbort);
}
}
} else {
if (!signals.has(signal)) {
signals.add(signal);
registerAbortSignalListener(signal, onAbort);
}
}
}
}
}
});
return ctrl.signal;
}
export { abortSignalAny, createTimeoutSignalWithDispose, isAbortSignalFromAny };
export { abortSignalAny };
{
"name": "@graphql-hive/gateway-abort-signal-any",
"version": "0.0.4-alpha-d8dc77bc27e4abf917b03c197fe569c509e54a72",
"version": "1.0.0-alpha-4105c094996f232c2b96db211bb33770260fcaef",
"type": "module",

@@ -36,18 +36,6 @@ "repository": {

},
"peerDependencies": {
"graphql": "^15.0.0 || ^16.9.0 || ^17.0.0"
},
"dependencies": {
"@graphql-tools/utils": "^10.7.0",
"@whatwg-node/disposablestack": "^0.0.5",
"tslib": "^2.8.1"
},
"devDependencies": {
"graphql": "^16.9.0",
"pkgroll": "2.6.0"
"pkgroll": "2.6.1"
},
"publishConfig": {
"access": "public"
},
"sideEffects": false
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc