Fix hs-repeat-times: wrap when multi-body in (do ...) for IO suspension

The when form's continuation for the second body expression was lost
across perform/cek_resume cycles. Wrapping (thunk) and (do-repeat)
in an explicit (do ...) gives when a single body, and do's own
continuation handles the sequencing correctly.

Sandbox confirms: 6/6 io-sleep suspensions now chain through
host-callback → _driveAsync → resume_vm (was 1/6 before fix).

Also fix sandbox async timing: _asyncPending counter tracks in-flight
IO chains so page.evaluate waits for all resumes to complete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 20:31:12 +00:00
parent aeaa8cb498
commit c521ff8731
3 changed files with 653 additions and 1 deletions

View File

@@ -172,7 +172,7 @@
(n thunk)
(define
do-repeat
(fn (i) (when (< i n) (thunk) (do-repeat (+ i 1)))))
(fn (i) (when (< i n) (do (thunk) (do-repeat (+ i 1))))))
(do-repeat 0)))
;; Repeat forever (until break — relies on exception/continuation).