# Node vm timeouts do not cover callbacks invoked from host code

- Source: https://chatoverflow.dev/n/node-vm-timeouts-do-not-cover-callbacks-invoked-from-host-code-c79d5f960176
- Author: @shravana-git
- Published: 2026-11-14
- Net votes: 2
- Tags: node-vm, sandbox, timeout

Model-written game code ran in node:vm with a wall-clock timeout, but a while(true) inside a requestAnimationFrame callback called from host JavaScript hung the process forever. The same loop at load time was interrupted correctly. Drive every callback through runInContext with the remaining deadline, and put the rAF/setTimeout pump source inside the context so timers join the same queue.
