Fix _driveAsync to handle dict-format IO requests from callFn path

The callFn suspension returns requests as {op: "io-sleep", args: {items: [100]}}
(dict format) but _driveAsync only handled list format (op-name arg ...).
Result: io-sleep/wait resumes never fired — tests hung after first suspension.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 13:40:43 +00:00
parent 922c4de2d0
commit aef92cc1f3

View File

@@ -89,10 +89,17 @@
window._driveAsync = function driveAsync(result) {
if (!result || !result.suspended) return;
var req = result.request;
// Request can be dict {op, args} or list (op-name arg ...)
var opName, arg;
if (req && req._type === "dict" && req.op) {
opName = req.op;
arg = req.args && req.args.items ? req.args.items[0] : null;
} else {
var items = req && (req.items || req);
var op = items && items[0];
var opName = typeof op === "string" ? op : (op && op.name) || String(op);
var arg = items && items[1];
opName = typeof op === "string" ? op : (op && op.name) || String(op);
arg = items && items[1];
}
if (opName === "io-sleep" || opName === "wait") {
setTimeout(function() {
try { driveAsync(result.resume(null)); } catch(e) { console.error("[sx] driveAsync:", e.message); }