Back to articles
When setTimeout Overflows and Your Agent Melts

When setTimeout Overflows and Your Agent Melts

via Dev.to JavaScriptWu Long

A token expiry heuristic misidentifies seconds as milliseconds, producing a 360 billion ms setTimeout. Node.js clamps it to 1ms. The gateway hits 100% CPU and never recovers. The Bug Imagine this: you upgrade your OpenClaw gateway, restart it, and within seconds your CPU pegs at 100%. Logs start flooding at 500MB/day. Your agent is completely unresponsive. The culprit? A setTimeout call with a 360 billion millisecond delay. OpenClaw #55360 documents one of those bugs that feels like it shouldn't be possible — until you understand how Node.js handles timer overflow. The Heuristic That Broke OpenClaw's GitHub Copilot integration needs to refresh tokens before they expire. The token response includes an expires_at field, but different providers return this as either seconds or milliseconds since epoch. The code uses a heuristic to guess which: if ( expiresAt > 10 _000_000_000 ) { // Must be milliseconds return expiresAt ; } else { // Must be seconds, convert return expiresAt * 1000 ; } Th

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
8 views

Related Articles