Merge pull request 'fix(shutdown): arm the teardown timer before the callback that clears it' (#44) from fix/teardown-timer-ordering into develop
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 16s
CI / runtimes (edge) (pull_request) Successful in 12s
Promote → GitHub / push-github (push) Successful in 7s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 13s
CI / build (push) Successful in 27s
CI / runtimes (deno) (push) Successful in 17s
CI / runtimes (edge) (push) Successful in 12s
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 14s
CI / build (pull_request) Successful in 23s
CI / runtimes (deno) (pull_request) Successful in 16s
CI / runtimes (edge) (pull_request) Successful in 12s
Promote → GitHub / push-github (push) Successful in 7s
CI / dco (push) Has been skipped
CI / runtimes (bun) (push) Successful in 13s
CI / build (push) Successful in 27s
CI / runtimes (deno) (push) Successful in 17s
CI / runtimes (edge) (push) Successful in 12s
This commit was merged in pull request #44.
This commit is contained in:
commit
6672185ba2
1 file changed
+11
-7
+11
-7
@@ -1095,13 +1095,9 @@ function runTeardown(teardown: TeardownRegistry, logger: Logger, budgetMs: numbe
|
|||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
let settled = false;
|
let settled = false;
|
||||||
|
|
||||||
const finish = (): void => {
|
// Armed before `finish` exists, for the reason spelled out in `closeApp` below: setTimeout
|
||||||
if (settled) return;
|
// cannot fire synchronously, so the forward reference to `finish` rests on a guarantee, while
|
||||||
settled = true;
|
// the reverse ordering would rest on `teardown.run().then()` deferring.
|
||||||
clearTimeout(timer);
|
|
||||||
resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
const timer = setTimeout(
|
const timer = setTimeout(
|
||||||
() => {
|
() => {
|
||||||
if (settled) return;
|
if (settled) return;
|
||||||
@@ -1114,6 +1110,14 @@ function runTeardown(teardown: TeardownRegistry, logger: Logger, budgetMs: numbe
|
|||||||
);
|
);
|
||||||
|
|
||||||
timer.unref?.();
|
timer.unref?.();
|
||||||
|
|
||||||
|
const finish = (): void => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
|
||||||
void teardown.run(logger).then(finish, finish);
|
void teardown.run(logger).then(finish, finish);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user