Skip to content

v8.0.0

Latest

Choose a tag to compare

@sindresorhus sindresorhus released this 15 Oct 12:12

Breaking

  • Require Node.js 22 c633f8f
  • Call .cancel() on the input on every timeout and abort (#47) d938bcd
    • Before, only a timeout without a fallback called it. Now a timeout with a fallback, an abort of signal, and an already aborted signal also call it.
    • Cancellation is best-effort. If .cancel() throws, the error is ignored and the promise still settles. Before, the error escaped the timer as an uncaught exception and the promise never settled.
    • .cancel() runs after the outcome is decided, so it cannot change the outcome.
    • A fallback that returns the input itself now gets a cancelled input.
  • Reject with the exact abort reason, even when it is null f2b3ae3
    • controller.abort(null) used to reject with a generic AbortError.

Improvements

  • Only create a TimeoutError when the timeout can reject with it bcc57d3
    • Capturing a stack trace is expensive, and most promises settle before the timeout.

Fixes

  • Fix timeouts above 2 ** 31 - 1 milliseconds firing immediately 7273802
    • They now never time out, the same as Infinity.
  • Fix custom clearTimeout being called with undefined when no timer exists f6e3d89
  • Fix cleanup failures changing the outcome or leaking the abort listener 0beb15c
  • Reject with a clear TypeError for invalid customTimers beaa523
    • Before, this failed with an unrelated error, or was ignored when the input settled synchronously or the timeout was Infinity.

v7.0.2...v8.0.0