Back to feed
Dev.to
Dev.to
5/8/2026
Owned Async Work In TypeScript. Promise.race Does Not Cancel Your Work

Owned Async Work In TypeScript. Promise.race Does Not Cancel Your Work

Short summary

Native Promise.race and Promise.all leave losing promises running, creating resource leaks and uncanceled I/O. WorkIt introduces an ownership model that cancels losing operations at the AbortSignal boundary, runs LIFO cleanup, and provides scoped concurrency, retry logic, timeouts, and token budgeting—with typed cancel reasons instead of strings.

  • Promise.race doesn't cancel losers; APIs, TCP connections, and tokens continue until timeout or caller cancels
  • WorkIt's ownership model cancels via AbortSignal, runs cleanup LIFO, and guarantees scope-bound work
  • Supports bounded concurrency, typed errors, retry with backoff, timeouts, and atomic budget enforcement

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Explore more