Skip to content

fix(start): don't log aborted server function requests as errors - #8412

Open
oztune wants to merge 1 commit into
TanStack:mainfrom
oztune:fix/serverfn-dont-log-aborts
Open

oztune wants to merge 1 commit into
TanStack:mainfrom
oztune:fix/serverfn-dont-log-aborts

Conversation

@oztune

@oztune oztune commented Sep 13, 2026

Copy link
Copy Markdown

Problem

serverFnFetcher's getResponse logs every non-Response error before rethrowing:

} catch (error) {
  if (error instanceof Response) {
    response = error
  } else {
    console.log(error) // <- logs even expected cancellations
    throw error
  }
}

This includes the AbortError thrown when the caller cancels a server-function request, which is normal, expected control flow — not a failure. The most common trigger is TanStack Query aborting a query when its component unmounts: navigating away while a server-fn-backed query is in flight spams the console with

AbortError: signal is aborted without reason

even though nothing is wrong — the request was intentionally cancelled.

Fix

Skip the log when the error is an abort (DOMException or any Error with name === 'AbortError'). The error is still rethrown, so callers (e.g. TanStack Query) handle the cancellation exactly as before, and genuine errors are still logged.

Tests

Added serverFnFetcher unit tests covering both branches:

  • an aborted request is not logged, but is still rethrown
  • a genuine error is logged and rethrown

A changeset is included (@tanstack/start-client-core, patch).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Aborted server-function requests no longer appear as logged errors.
    • Genuine server-function errors continue to be logged and rethrown.
    • Aborted requests and other errors preserve their original error details.

`serverFnFetcher` logged every non-`Response` error before rethrowing,
including the `AbortError` produced when the caller cancels the request
(e.g. TanStack Query aborting a query when its component unmounts).
Cancellation is expected control flow, so it is no longer logged; genuine
errors are still logged and all errors are still rethrown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c0d55729-ab29-4fc2-9dc8-a06ffa662706

📥 Commits

Reviewing files that changed from the base of the PR and between 6954a37 and aabf663.

📒 Files selected for processing (3)
  • .changeset/serverfn-dont-log-aborts.md
  • packages/start-client-core/src/client-rpc/serverFnFetcher.ts
  • packages/start-client-core/tests/serverFnFetcher.test.ts

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


📝 Walkthrough

Walkthrough

serverFnFetcher now suppresses logging for AbortError cancellations. It still logs genuine errors and rethrows every error. Tests verify both behaviors, and a patch changeset documents the change.

Changes

Server-function abort handling

Layer / File(s) Summary
Abort error detection and handling
packages/start-client-core/src/client-rpc/serverFnFetcher.ts
The fetcher detects errors with name === 'AbortError'. It skips logging for those errors and rethrows them. Other errors remain logged and rethrown.
Error handling validation and release note
packages/start-client-core/tests/serverFnFetcher.test.ts, .changeset/serverfn-dont-log-aborts.md
Tests verify that abort errors are not logged and genuine errors are logged. Both errors are rethrown. The changeset records the patch release update.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to aabf6

Aborted requests avoid expected error-log noise while genuine failures remain visible and all errors are still rethrown. No merge-blocking risk is evident.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preventing error logging for aborted server-function requests.
Description check ✅ Passed The description explains the problem, fix, tests, and release impact. It omits the required checklist section and does not explicitly confirm the checklist items, but the main required change informat…
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

console.log(error)
// A caller aborting the request is expected control flow, not a failure, so don't log it.
// We still rethrow so the caller can handle the cancellation.
if (!isAbortError(error)) {

@Sheraff Sheraff Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably the only test we need is this

Suggested change
if (!isAbortError(error)) {
if (!(error instanceof Error) || error.name !== 'AbortError') {

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.

2 participants