mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 00:21:05 -05:00
fix: unref stdin read (#23534)
Closes https://github.com/denoland/deno_core/issues/648 Co-authored-by: Matt Mastracci <matthew@mastracci.com>
This commit is contained in:
parent
1de162f1c1
commit
115dedde22
4 changed files with 24 additions and 1 deletions
|
@ -99,7 +99,13 @@ where
|
|||
#[cfg(not(tokio_unstable))]
|
||||
let join_handle = rt.spawn(future);
|
||||
|
||||
rt.block_on(join_handle).unwrap().into_inner()
|
||||
let r = rt.block_on(join_handle).unwrap().into_inner();
|
||||
// Forcefully shutdown the runtime - we're done executing JS code at this
|
||||
// point, but there might be outstanding blocking tasks that were created and
|
||||
// latered "unrefed". They won't terminate on their own, so we're forcing
|
||||
// termination of Tokio runtime at this point.
|
||||
rt.shutdown_background();
|
||||
r
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
5
tests/specs/run/unref_stdin/__test__.jsonc
Normal file
5
tests/specs/run/unref_stdin/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Regression test for https://github.com/denoland/deno/issues/22453
|
||||
{
|
||||
"args": "run main.js",
|
||||
"output": "main.out"
|
||||
}
|
11
tests/specs/run/unref_stdin/main.js
Normal file
11
tests/specs/run/unref_stdin/main.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
const { core } = Deno[Deno.internal];
|
||||
const opPromise = core.read(Deno.stdin.rid, new Uint8Array(10));
|
||||
core.unrefOpPromise(opPromise);
|
||||
|
||||
async function main() {
|
||||
console.log(1);
|
||||
await opPromise;
|
||||
console.log(2);
|
||||
}
|
||||
|
||||
main();
|
1
tests/specs/run/unref_stdin/main.out
Normal file
1
tests/specs/run/unref_stdin/main.out
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
Loading…
Reference in a new issue