Book: TypeScript Essentials
Also by me: The TypeScript Library β the 5-book collection
My project: Hermes IDE | GitHub β an IDE for developers who ship with Claude Code and other AI coding tools
Me: xgabriel.com | GitHub
Your function promised to give up after two seconds, and it did. It threw a nice Error("timed out") , the caller logged it, the user saw a retry button. Meanwhile the HTTP request it was supposed to abandon kept downloading for another forty seconds, holding a socket, filling a buffer nobody would ever read.
That is what a hand-rolled timeout built on setTimeout and Promise.race does. It stops waiting . It never stops the work .
The fix has been sitting in every runtime for a while. Node.js added AbortSignal.timeout() in v17.3.0 and v16.14.0, and AbortSignal.any() in v20.3.0 and v18.17.0. MDN marks AbortSignal.any() as available across browsers since March 2024, and AbortSignal.timeout() since April 2024.β¦