1
0
Fork 0
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:
Bartek Iwańczuk 2024-04-25 06:32:01 +01:00 committed by GitHub
parent 1de162f1c1
commit 115dedde22
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 1 deletions

View file

@ -99,7 +99,13 @@ where
#[cfg(not(tokio_unstable))] #[cfg(not(tokio_unstable))]
let join_handle = rt.spawn(future); 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)] #[inline(always)]

View file

@ -0,0 +1,5 @@
// Regression test for https://github.com/denoland/deno/issues/22453
{
"args": "run main.js",
"output": "main.out"
}

View 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();

View file

@ -0,0 +1 @@
1