Skip to content

Commit 31a5287

Browse files
committed
capture variable in scope
1 parent 054ffa7 commit 31a5287

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/link/http/BaseHttpLink.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,16 @@ export class BaseHttpLink extends ApolloLink {
9595
controller = undefined;
9696
};
9797
if (options.signal) {
98+
const externalSignal = options.signal;
9899
// in an ideal world we could use `AbortSignal.any` here, but
99100
// React Native uses https://github.com/mysticatea/abort-controller as
100101
// a polyfill for `AbortController`, and it does not support `AbortSignal.any`.
101102
const abort = controller.abort.bind(controller);
102-
options.signal.addEventListener("abort", abort, { once: true });
103+
externalSignal.addEventListener("abort", abort, { once: true });
103104
cleanupController = () => {
104105
controller = undefined;
105106
// on cleanup, we need to stop listening to `options.signal` to avoid memory leaks
106-
options.signal.removeEventListener("abort", abort);
107+
externalSignal.removeEventListener("abort", abort);
107108
cleanupController = noop;
108109
};
109110
// react native also does not support the addEventListener `signal` option

0 commit comments

Comments
 (0)