summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/40_fs_events.js6
-rw-r--r--runtime/js/40_process.js22
-rw-r--r--runtime/js/99_main.js19
3 files changed, 36 insertions, 11 deletions
diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js
index 4c2f5fc9a..b10f6fd10 100644
--- a/runtime/js/40_fs_events.js
+++ b/runtime/js/40_fs_events.js
@@ -9,6 +9,8 @@ const {
PromiseResolve,
SymbolAsyncIterator,
} = primordials;
+import { SymbolDispose } from "ext:deno_web/00_infra.js";
+
class FsWatcher {
#rid = 0;
@@ -51,6 +53,10 @@ class FsWatcher {
[SymbolAsyncIterator]() {
return this;
}
+
+ [SymbolDispose]() {
+ core.tryClose(this.#rid);
+ }
}
function watchFs(
diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js
index 664a4b303..4ddc4a02a 100644
--- a/runtime/js/40_process.js
+++ b/runtime/js/40_process.js
@@ -18,7 +18,11 @@ const {
} = primordials;
import { FsFile } from "ext:deno_fs/30_fs.js";
import { readAll } from "ext:deno_io/12_io.js";
-import { assert, pathFromURL } from "ext:deno_web/00_infra.js";
+import {
+ assert,
+ pathFromURL,
+ SymbolAsyncDispose,
+} from "ext:deno_web/00_infra.js";
import * as abortSignal from "ext:deno_web/03_abort_signal.js";
import {
readableStreamCollectIntoUint8Array,
@@ -201,7 +205,6 @@ class ChildProcess {
#rid;
#waitPromiseId;
#waitComplete = false;
- #unrefed = false;
#pid;
get pid() {
@@ -216,7 +219,6 @@ class ChildProcess {
return this.#stdin;
}
- #stdoutRid;
#stdout = null;
get stdout() {
if (this.#stdout == null) {
@@ -225,7 +227,6 @@ class ChildProcess {
return this.#stdout;
}
- #stderrRid;
#stderr = null;
get stderr() {
if (this.#stderr == null) {
@@ -254,12 +255,10 @@ class ChildProcess {
}
if (stdoutRid !== null) {
- this.#stdoutRid = stdoutRid;
this.#stdout = readableStreamForRidUnrefable(stdoutRid);
}
if (stderrRid !== null) {
- this.#stderrRid = stderrRid;
this.#stderr = readableStreamForRidUnrefable(stderrRid);
}
@@ -324,15 +323,22 @@ class ChildProcess {
ops.op_spawn_kill(this.#rid, signo);
}
+ async [SymbolAsyncDispose]() {
+ try {
+ ops.op_spawn_kill(this.#rid, "SIGTERM");
+ } catch {
+ // ignore errors from killing the process (such as ESRCH or BadResource)
+ }
+ await this.#status;
+ }
+
ref() {
- this.#unrefed = false;
core.refOp(this.#waitPromiseId);
if (this.#stdout) readableStreamForRidUnrefableRef(this.#stdout);
if (this.#stderr) readableStreamForRidUnrefableRef(this.#stderr);
}
unref() {
- this.#unrefed = true;
core.unrefOp(this.#waitPromiseId);
if (this.#stdout) readableStreamForRidUnrefableUnref(this.#stdout);
if (this.#stderr) readableStreamForRidUnrefableUnref(this.#stderr);
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index ccc61036a..ac1f52e74 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -70,11 +70,24 @@ import {
windowOrWorkerGlobalScope,
workerRuntimeGlobalProperties,
} from "ext:runtime/98_global_scope.js";
+import { SymbolAsyncDispose, SymbolDispose } from "ext:deno_web/00_infra.js";
// deno-lint-ignore prefer-primordials
-Symbol.dispose ??= Symbol("Symbol.dispose");
-// deno-lint-ignore prefer-primordials
-Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
+if (Symbol.dispose) throw "V8 supports Symbol.dispose now, no need to shim it!";
+ObjectDefineProperties(Symbol, {
+ dispose: {
+ value: SymbolDispose,
+ enumerable: false,
+ writable: false,
+ configurable: false,
+ },
+ asyncDispose: {
+ value: SymbolAsyncDispose,
+ enumerable: false,
+ writable: false,
+ configurable: false,
+ },
+});
let windowIsClosing = false;
let globalThis_;