Skip to content

feat: add manual cancellation for queries and mutations - #49

Merged
MelvishNiz merged 1 commit into
mainfrom
codex/tambahkan-fitur-manual-cancel-untuk-query
Jun 26, 2026
Merged

MelvishNiz merged 1 commit into
mainfrom
codex/tambahkan-fitur-manual-cancel-untuk-query

Conversation

@MelvishNiz

Copy link
Copy Markdown
Collaborator

Motivation

  • Provide a simple manual cancel() API so callers can abort in-flight query or mutation requests and immediately reset loading state.
  • Ensure canceled requests do not trigger local or global error handlers or surface spurious error messages.
  • Support using standard AbortController signals with Axios so cancellation integrates with existing browser/Fetch semantics.

Description

  • Added per-hook cancellation using AbortController for queries and mutations and wired request signal into Axios requests in src/core/client.ts.
  • Added isCanceledError helper to detect canceled requests and early-return to avoid invoking error handlers, and updated error handling accordingly.
  • Extended public types in src/core/types.ts to include cancel: () => void on QueryResult and MutationResult and returned cancel from hook factories.
  • Added runtime tests in tests/client-runtime.test.ts to cover exposing cancel() for queries and mutations and to verify canceled requests do not call error handlers.

Testing

  • Ran unit test suite with npm test (Vitest); all tests passed (114 tests passed).
  • Built the package with npm run build; the build completed successfully.
  • Verified the added runtime tests specifically for cancellation and that canceled requests are suppressed from error handlers.

Codex Task

@MelvishNiz
MelvishNiz merged commit 299e3f2 into main Jun 26, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant