Phase F fix: open-lane token was lost across the dispatch-context swap — mint it in JS; repro spec added

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Td4ujboGuAw26jvbDQzehj
This commit is contained in:
Gergő Törcsvári 2026-08-09 17:44:33 +02:00
commit 1d8237bc08
No known key found for this signature in database
GPG key ID: 8E75F2CDE64E5322
5 changed files with 180 additions and 10 deletions

View file

@ -153,7 +153,12 @@ if (typeof Asyncify !== "undefined" && !globalThis.__wxSchedulerInstalled) {
var start = Module["kicadOpenFileStart"];
if (typeof start !== "function" || typeof Module["kicadOpenFile"] !== "function") return;
Module["kicadOpenFile"] = function (path) {
var token = start(path);
// Mint the token HERE, in pure JS — the starter runs the load on a
// dispatch context and Asyncify-suspends its own frame, so a token
// RETURNED from it would arrive as a placeholder (0). We own the token
// and await its promise; the job resolves it when the load finishes.
var token = self.beginWait("open");
start(token, path);
// waitPromise consumes early-resolved entries (the fast-error path),
// so a job that finished before this await still resolves correctly.
return self.waitPromise(token).then(function (r) { return !!r; });