Add AbortSignal support to createTimeout#381
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add signal to async utilities and hooks
Add Apr 8, 2026
AbortSignal support to createTimeout
Agent-Logs-Url: https://github.com/mediamonks/react-kit/sessions/268ea3b9-4071-4c02-8e91-43b6a88c8bbf Co-authored-by: ThaNarie <1449580+ThaNarie@users.noreply.github.com>
ThaNarie
approved these changes
Apr 8, 2026
There was a problem hiding this comment.
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
createTimeoutto accept an optional{ signal }and reject when aborted. - Update
TransitionPresenceto pass an abort signal into tick delays and to handle abort-related rejections. - Add tests and documentation covering
AbortSignalusage forcreateTimeout.
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.
…sence Agent-Logs-Url: https://github.com/mediamonks/react-kit/sessions/253df10c-79a1-4d0c-943a-7d752ef07d7b Co-authored-by: ThaNarie <1449580+ThaNarie@users.noreply.github.com>
ThaNarie
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createTimeout— already hasAbortSignalsupportTransitionPresence— pass{ signal: abortController.signal }to bothcreateTimeout()calls so mid-transition aborts fully short-circuitTransitionPresence— catch now only swallowserror === abortController.signal.reason; any other error (even when aborted) is re-thrown with{ cause: error }so stack traces are preserved