Skip to content

test({query-core,react-query,preact-query,solid-query}): pass 'unhandledRejectionFn' directly so 'process.off' removes the 'unhandledRejection' listener - #11610

Open
sukvvon wants to merge 4 commits into
mainfrom
test/fix-unhandled-rejection-listener-removal
Open

sukvvon wants to merge 4 commits into
mainfrom
test/fix-unhandled-rejection-listener-removal

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 24, 2026

Copy link
Copy Markdown
Member

🎯 Changes

These tests registered an inline wrapper with process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) but removed unhandledRejectionFn in onTestFinished. Since process.off only removes the exact function that was registered, the wrapper was never removed and kept handling unhandled rejections for the rest of the test file.

unhandledRejectionFn is now passed directly to process.on, so the existing process.off removes it:

  • query-core: mutation.test.tsx (3), mutationObserver.test.tsx (2)
  • react-query, preact-query, solid-query: useMutation.test.tsx (2 each)

Since the listener now receives Node's (reason, promise) arguments, the unhandledRejectionFn assertions in query-core add expect.any(Promise) as the second argument. The other packages do not assert on unhandledRejectionFn.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Improved coverage of rejected mutation callbacks by verifying that unhandled rejections include the associated promise.
    • Simplified rejection-listener setup across mutation tests.

…nFn' directly so 'process.off' removes the 'unhandledRejection' listener
…o 'process.off' removes the 'unhandledRejection' listener
…so 'process.off' removes the 'unhandledRejection' listener
…o 'process.off' removes the 'unhandledRejection' listener
@nx-cloud

nx-cloud Bot commented Sep 24, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 00e505f

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 5m 4s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 40s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-24 05:32:03 UTC

@sukvvon sukvvon self-assigned this Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 7eca59ec-ed28-4505-8137-e5009ed849c2

📥 Commits

Reviewing files that changed from the base of the PR and between 645291a and 00e505f.

📒 Files selected for processing (5)
  • packages/preact-query/src/__tests__/useMutation.test.tsx
  • packages/query-core/src/__tests__/mutation.test.tsx
  • packages/query-core/src/__tests__/mutationObserver.test.tsx
  • packages/react-query/src/__tests__/useMutation.test.tsx
  • packages/solid-query/src/__tests__/useMutation.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Mutation tests across query-core and three framework adapters now register unhandled-rejection mocks directly. Query-core tests also check that rejection events include a Promise argument.

Changes

Mutation rejection tests

Layer / File(s) Summary
Listener registration and rejection assertions
packages/query-core/src/__tests__/mutation.test.tsx, packages/query-core/src/__tests__/mutationObserver.test.tsx, packages/preact-query/src/__tests__/useMutation.test.tsx, packages/react-query/src/__tests__/useMutation.test.tsx, packages/solid-query/src/__tests__/useMutation.test.tsx
Tests pass the mock directly as the unhandled-rejection listener. Query-core assertions also check that the listener receives a Promise as its second argument.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 00e50

This PR updates rejection-listener tests without introducing an identified merge risk. It is ready to merge after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main test change: passing unhandledRejectionFn directly so process.off can remove the listener. It is specific, although longer than necessary.
Description check ✅ Passed The description explains the cause, the affected tests, the assertion updates, checklist completion, and the dev-only release impact. It matches the required template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11610

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11610

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11610

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11610

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11610

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11610

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11610

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11610

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11610

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11610

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11610

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11610

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11610

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11610

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11610

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11610

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11610

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11610

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11610

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11610

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11610

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11610

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11610

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11610

commit: 00e505f

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.87 KB (0%)
react minimal 8.85 KB (0%)

This branch has not been deployed

No deployments
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.

1 participant