Commit b5a87eb
`QuickJSScriptRunner.installCtx` serialised the hook context into the
sandbox with a bare `JSON.stringify`. A live `setTimeout`/`setInterval`
handle reachable from `ctx` links back on itself
(`Timeout._idlePrev -> TimersList._idleNext -> …`), so `JSON.stringify`
threw `TypeError: Converting circular structure to JSON` and took the
whole hook down.
Route all three host→VM marshalling paths (`setGlobalJson`,
`setObjectJson`, `jsonToHandle`) through a shared `safeJsonStringify`
that drops circular back-edges via a path `WeakSet` and coerces `BigInt`
to a string. Only JSON-safe leaves cross the boundary — unserialisable
host objects are stripped rather than fatal — and the body still runs.
Closes #2674.
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0adcc1c commit b5a87eb
3 files changed
Lines changed: 77 additions & 3 deletions
File tree
- .changeset
- packages/runtime/src/sandbox
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
165 | 200 | | |
166 | 201 | | |
167 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
572 | 604 | | |
573 | 605 | | |
574 | | - | |
| 606 | + | |
575 | 607 | | |
576 | 608 | | |
577 | 609 | | |
| |||
582 | 614 | | |
583 | 615 | | |
584 | 616 | | |
585 | | - | |
| 617 | + | |
586 | 618 | | |
587 | 619 | | |
588 | 620 | | |
| |||
593 | 625 | | |
594 | 626 | | |
595 | 627 | | |
596 | | - | |
| 628 | + | |
597 | 629 | | |
598 | 630 | | |
599 | 631 | | |
| |||
0 commit comments