diff options
author | Tom Alcorn <tdb.alcorn@gmail.com> | 2024-06-18 14:47:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 07:47:05 +1000 |
commit | 5289c69271fed638571580bfb120c41bd6ea4372 (patch) | |
tree | 9a88f81d6df07a4a6706e66dd97e610b89dd463e /ext/web/03_abort_signal.js | |
parent | cba212b9c63f80b73994cf6012c5db83b31eefc9 (diff) |
fix(ext/web): fix `AbortSignal.timeout()` leak (#23842)
<!--
Before submitting a PR, please read
https://docs.deno.com/runtime/manual/references/contributing
1. Give the PR a descriptive title.
Examples of good title:
- fix(std/http): Fix race condition in server
- docs(console): Update docstrings
- feat(doc): Handle nested reexports
Examples of bad title:
- fix #7123
- update docs
- fix bugs
2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
Fixes #20663.
---------
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'ext/web/03_abort_signal.js')
-rw-r--r-- | ext/web/03_abort_signal.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ext/web/03_abort_signal.js b/ext/web/03_abort_signal.js index 053b89bdf..81844d53f 100644 --- a/ext/web/03_abort_signal.js +++ b/ext/web/03_abort_signal.js @@ -3,7 +3,7 @@ // @ts-check /// <reference path="../../core/internal.d.ts" /> -import { primordials } from "ext:core/mod.js"; +import { core, primordials } from "ext:core/mod.js"; const { ArrayPrototypeEvery, ArrayPrototypePush, @@ -33,7 +33,7 @@ import { listenerCount, setIsTrusted, } from "./02_event.js"; -import { refTimer, setTimeout, unrefTimer } from "./02_timers.js"; +import { clearTimeout, refTimer, unrefTimer } from "./02_timers.js"; // Since WeakSet is not a iterable, WeakRefSet class is provided to store and // iterate objects. @@ -118,14 +118,17 @@ class AbortSignal extends EventTarget { ); const signal = new AbortSignal(illegalConstructorKey); - signal[timerId] = setTimeout( + signal[timerId] = core.queueSystemTimer( + undefined, + false, + millis, () => { + clearTimeout(signal[timerId]); signal[timerId] = null; signal[signalAbort]( new DOMException("Signal timed out.", "TimeoutError"), ); }, - millis, ); unrefTimer(signal[timerId]); return signal; |