TypeScript SDK: concurrent shutdown calls cause durable eviction ACK timeouts
The TypeScript SDK can run shutdown concurrently when an application calls worker.stop() from its signal handler and the SDK’s own signal handler also runs.
Both calls enter evictAllWaiting(). Concurrent eviction requests for the same task and invocation overwrite the pending ACK waiter, so one caller times out after 30 s even when both requests receive ACKs. One shutdown call can also close the durable listener while another is still evicting runs.
I reproduced this on current main with regression tests covering overlapping signal handlers and stop(), ACK delivery, timeout, and listener shutdown. The proposed fix shares one shutdown operation and deduplicates pending eviction requests.
AI disclosure: OpenCode with GPT-6 Astra assisted with diagnosis, implementation, tests, and this draft.
Source: hatchet-dev/hatchet