Cancelling Timers with AbortController: Seven Cases Including Cleanup
AbortController can cancel more than fetch, but calling abort() does not halt an arbitrary Promise; the operation itself must accept the signal, stop waiting, and reject. The author tested a cancellable delay function before start, during its wait, and after completion, checking both rejection and whether abort listeners were removed. The function checks whether the signal is already aborted, registers a timer and an abort listener, and on abort clears the timer, removes the listener, and rejects with the signal's reason. In an example with two timers sharing one signal, aborting rejected both with the same error and cleared their listeners. The tests ran on macOS arm64 with Node.js 24.15.0 and were conducted on September 11, 2026.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in