fix(process): decode bounded worker control frames as strict UTF-8 (#12162)

* fix(process): decode analyzer worker control frames as strict UTF-8

Refs #12145.

* fix(process): decode bounded control input without byte replacement

* fix(android): bound guardian readiness by the first UTF-8 frame (#12176)

Follows the readiness framing and lifecycle findings reported by @LcokHcak in #3048.
This commit is contained in:
morluto
2026-11-19 04:00:02 +00:00
committed by GitHub
parent 85ac88fe87
commit 3493d6d252
15 changed files with 496 additions and 208 deletions
@@ -95,10 +95,13 @@ export const serveJavaScriptAnalysisWorker = async (
for (;;) {
const next = await requests.next();
if (next.done) break;
if (!next.value.ok)
if (!next.value.ok) {
if (next.value.error._tag === "ControlLineMalformedUtf8")
throw new TypeError("JavaScript worker request is not valid UTF-8");
throw new RangeError(
"JavaScript worker request exceeds its byte budget",
);
}
const raw: unknown = JSON.parse(next.value.value);
const request = javaScriptWorkerRequestSchema.parse(raw);
// Function scope releases source AST/IR/results before accepting another job.
@@ -182,6 +185,14 @@ const analyzeJob = async (
sha256: sha256Hex(text),
});
const next = await requests.next();
if (
!next.done &&
!next.value.ok &&
next.value.error._tag === "ControlLineMalformedUtf8"
)
throw new TypeError(
"JavaScript worker admission frame is not valid UTF-8",
);
if (next.done || !next.value.ok)
throw new TypeError(
"JavaScript worker admission frame is missing or oversized",