From 89142cb0115f92715223cd068792ae2e656519c0 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sun, 22 Sep 2024 21:43:25 -0400 Subject: [PATCH] Fix remainingTimeout calculation --- src/compiler/threading/condition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/threading/condition.ts b/src/compiler/threading/condition.ts index f16007fdd00..bd562f74f30 100644 --- a/src/compiler/threading/condition.ts +++ b/src/compiler/threading/condition.ts @@ -74,7 +74,7 @@ export class Condition extends Tagged(SharedStructBase, Tag.Condition) { mutex["_locked"] = false; // eslint-disable-line dot-notation -- declared `private` Atomics.Condition.notify(nativeCondition); try { - const remainingTimeout = isFinite(absoluteTimeout) ? Date.now() - absoluteTimeout : undefined; + const remainingTimeout = isFinite(absoluteTimeout) ? absoluteTimeout - Date.now() : undefined; const result = Atomics.Condition.wait(self._condition, nativeMutex, remainingTimeout) ? "ok" : "timed-out"; if (result === "timed-out") { return stopWaiting ? stopWaiting() : result;