diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-12-30 20:30:55 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-30 20:30:55 +0530 |
commit | 3db9c8742d986bb492cb87687c4a6bae357c956c (patch) | |
tree | b5ffd9d2485ba4d092d5c6423e7a239ba73c2836 | |
parent | a7b21760fce4780671db1d3d534b1d0d3c121ce7 (diff) |
fix(ext/node): add process.abort() (#21742)
-rw-r--r-- | ext/node/lib.rs | 1 | ||||
-rw-r--r-- | ext/node/ops/os/mod.rs | 5 | ||||
-rw-r--r-- | ext/node/polyfills/process.ts | 7 |
3 files changed, 13 insertions, 0 deletions
diff --git a/ext/node/lib.rs b/ext/node/lib.rs index 36f0fede9..3c19d30b1 100644 --- a/ext/node/lib.rs +++ b/ext/node/lib.rs @@ -282,6 +282,7 @@ deno_core::extension!(deno_node, ops::os::op_node_os_username<P>, ops::os::op_geteuid<P>, ops::os::op_cpus<P>, + ops::os::op_process_abort, op_node_build_os, op_node_is_promise_rejected, op_npm_process_state, diff --git a/ext/node/ops/os/mod.rs b/ext/node/ops/os/mod.rs index 4fadc1ff8..bba4ab900 100644 --- a/ext/node/ops/os/mod.rs +++ b/ext/node/ops/os/mod.rs @@ -75,6 +75,11 @@ where Ok(euid) } +#[op2(fast)] +pub fn op_process_abort() { + std::process::abort(); +} + #[op2] #[serde] pub fn op_cpus<P>(state: &mut OpState) -> Result<Vec<cpus::CpuInfo>, AnyError> diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index a85351d4b..449a85c5e 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -98,6 +98,10 @@ export const exit = (code?: number | string) => { process.reallyExit(process.exitCode || 0); }; +export const abort = () => { + ops.op_process_abort(); +}; + function addReadOnlyProcessAlias( name: string, option: string, @@ -415,6 +419,9 @@ class Process extends EventEmitter { /** https://nodejs.org/api/process.html#process_process_exit_code */ exit = exit; + /** https://nodejs.org/api/process.html#processabort */ + abort = abort; + // Undocumented Node API that is used by `signal-exit` which in turn // is used by `node-tap`. It was marked for removal a couple of years // ago. See https://github.com/nodejs/node/blob/6a6b3c54022104cc110ab09044a2a0cecb8988e7/lib/internal/bootstrap/node.js#L172 |