Skip to content

Add AbortSignal support to createTimeout#381

Merged
ThaNarie merged 4 commits intomainfrom
copilot/add-signal-to-async-utilities
Apr 8, 2026
Merged

Add AbortSignal support to createTimeout#381
ThaNarie merged 4 commits intomainfrom
copilot/add-signal-to-async-utilities

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

  • createTimeout — already has AbortSignal support
  • TransitionPresence — pass { signal: abortController.signal } to both createTimeout() calls so mid-transition aborts fully short-circuit
  • TransitionPresence — catch now only swallows error === abortController.signal.reason; any other error (even when aborted) is re-thrown with { cause: error } so stack traces are preserved

Copilot AI linked an issue Apr 8, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add signal to async utilities and hooks Add AbortSignal support to createTimeout Apr 8, 2026
Copilot AI requested a review from ThaNarie April 8, 2026 09:16
@ThaNarie ThaNarie marked this pull request as ready for review April 8, 2026 10:52
@ThaNarie ThaNarie requested a review from Copilot April 8, 2026 10:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds AbortSignal-aware timeout behavior and wires it into TransitionPresence so that in-flight transitions can be cancelled cleanly (e.g., on unmount or rapid child changes).

Changes:

  • Extend createTimeout to accept an optional { signal } and reject when aborted.
  • Update TransitionPresence to pass an abort signal into tick delays and to handle abort-related rejections.
  • Add tests and documentation covering AbortSignal usage for createTimeout.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/utils/createTimeout/createTimeout.ts Adds { signal } option to allow aborting the timeout promise.
src/utils/createTimeout/createTimeout.test.ts Adds coverage for aborted signals and abort reasons.
src/utils/createTimeout/createTimeout.mdx Updates API docs and adds an AbortSignal usage example.
src/lifecycle/components/TransitionPresence/TransitionPresence.tsx Passes AbortSignal through tick delays and adds try/catch handling for abort scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lifecycle/components/TransitionPresence/TransitionPresence.tsx
Copilot AI requested a review from ThaNarie April 8, 2026 11:27
@ThaNarie ThaNarie merged commit a3585cd into main Apr 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add signal to async utilities and hooks

3 participants