worker: avoid idle consumer blocking shared compute gate

This commit is contained in:
Richard R 2026-05-21 20:06:24 -06:00
parent 4664806ba0
commit 51fbfa117d

View file

@ -1167,12 +1167,6 @@ async function main(): Promise<void> {
workerLabel: string; workerLabel: string;
}): Promise<void> { }): Promise<void> {
while (!stopping) { while (!stopping) {
await jobGate.acquire();
if (stopping) {
jobGate.release();
return;
}
let msg: JsMsg | null = null; let msg: JsMsg | null = null;
try { try {
try { try {
@ -1185,6 +1179,11 @@ async function main(): Promise<void> {
} }
if (!msg) continue; if (!msg) continue;
await jobGate.acquire();
if (stopping) {
jobGate.release();
return;
}
await processMessage({ await processMessage({
msg, msg,
codec: input.codec, codec: input.codec,
@ -1192,7 +1191,9 @@ async function main(): Promise<void> {
workerLabel: input.workerLabel, workerLabel: input.workerLabel,
}); });
} finally { } finally {
jobGate.release(); if (msg) {
jobGate.release();
}
} }
} }
} }