Repository navigation
feat(runtime): clamp oversized setTimeout/setInterval delays to avoid Node TimeoutOverflowWarning #3769
yuntaojinghong
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
When plugin (or AI-generated) code calls
setTimeout/setIntervalwith a delay larger than2^31 - 1ms (e.g.setInterval(cb, 99999999000), ~1157 days), Node.js emits aTimeoutOverflowWarningand silently clamps the actual delay to 1 ms — the timer then fires almost immediately, causing confusing behavior and tight polling loops.Observed
This happened while developing the
dsh-balance-monitorplugin: an AI-assisted snippet usedsetInterval(cb, 99999999000). Node clamped it to 1 ms and printed the overflow warning to the terminal.Current state (verified against the installed
@deepseek-ai/dsh)@deepseek-ai/dsh-code-runtime-worker-threadalready guards its own watchdog timer: in the constructor,this.config.maxWallMs = Math.min(this.config.maxWallMs, 60000)(lib/index.js L665), so the runtime'ssetTimeout(..., this.config.maxWallMs)can never exceed 60 s. That path is safe.The residual gap: the runtime cannot intercept arbitrary
setTimeout/setIntervalcalls made inside executed plugin code (worker thread). Those go straight to Node's native timers, so an oversized value still triggersTimeoutOverflowWarning+ 1 ms clamping.Suggested fix
2^31 - 1ms are unsupported; ortimershim inside the code runtime that clamps delays toMAX_TIMER_DELAY_MSwith a friendly warning instead of Node's raw warning, e.g.:Either way, the platform should be the last line of defense for AI-generated or misconfigured values.
Mitigation on the plugin side
dsh-balance-monitorv1.0.7 now clamps its configurable intervals at the config layer (auto-check ≤ 24 h, force-check ≤ 7 d), so it can never produce oversized delays again.Environment
@deepseek-ai/dsh-code-runtime-worker-threadAll reactions