1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 21:50:00 -05:00

fix(runtime): fix signal promise API (#11069)

This commit is contained in:
Yoshiya Hinosawa 2021-06-22 15:17:44 +09:00 committed by Ryan Dahl
parent 502f58f888
commit 7801e7cc43
2 changed files with 38 additions and 1 deletions

View file

@ -154,6 +154,35 @@ unitTest(
},
);
// https://github.com/denoland/deno/issues/9806
unitTest(
{ ignore: Deno.build.os === "windows", perms: { run: true } },
async function signalPromiseTest2(): Promise<void> {
const resolvable = deferred();
// This prevents the program from exiting.
const t = setInterval(() => {}, 1000);
let called = false;
const sig = Deno.signal(Deno.Signal.SIGUSR1);
sig.then(() => {
called = true;
});
setTimeout(() => {
sig.dispose();
setTimeout(() => {
resolvable.resolve();
}, 10);
}, 10);
clearInterval(t);
await resolvable;
// Promise callback is not called because it didn't get
// the corresponding signal.
assert(!called);
},
);
unitTest(
{ ignore: Deno.build.os === "windows", perms: { run: true } },
function signalShorthandsTest(): void {

View file

@ -236,7 +236,15 @@
f,
g,
) {
return this.#pollingPromise.then(() => {}).then(f, g);
return this.#pollingPromise.then((done) => {
if (done) {
// If pollingPromise returns true, then
// this signal stream is finished and the promise API
// should never be resolved.
return new Promise(() => {});
}
return;
}).then(f, g);
}
async next() {