Skip to content

test: add regression coverage for existing router behavior#7812

Merged
Sheraff merged 1 commit into
mainfrom
test/already-fixed-router-issues
Jul 13, 2026
Merged

test: add regression coverage for existing router behavior#7812
Sheraff merged 1 commit into
mainfrom
test/already-fixed-router-issues

Conversation

@Sheraff

@Sheraff Sheraff commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add regression coverage for root pending UI, head after beforeLoad errors, and canonical search normalization aborts
  • cover pending redirect chains and router.invalidate() inside React transitions
  • keep these already-green tests independent from the router loader rewrite in fix(router-core): lane match loader rewrite #7805
  • no production code changes

Issues covered

Refs #2182
Refs #2905
Refs #4684
Refs #6371
Refs #7367
Refs #7457
Refs #7638

The direct #7120 regression already exists on main, so this PR does not duplicate it.

Test plan

  • pnpm test:eslint
  • pnpm test:types
  • pnpm test:unit
  • focused router-core and React Router unit test runs

Summary by CodeRabbit

  • Bug Fixes
    • Improved routing behavior during pending states, redirects, and redirect chains.
    • Ensured invalidated routes reload correctly and recover without React rendering crashes.
    • Preserved route metadata when loading errors occur.
    • Prevented aborted requests during search normalization from surfacing as route errors or causing repeated loads.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds six regression test suites covering React Router pending and redirect flows, invalidation transition errors, route head execution after beforeLoad failures, and aborted loads during search-default normalization.

Changes

React router navigation regressions

Layer / File(s) Summary
Pending UI and redirect flows
packages/react-router/tests/issue-2182-root-pending.test.tsx, packages/react-router/tests/issue-7367-pending-min-redirect.test.tsx, packages/react-router/tests/issue-7457-redirect-chain-first-load.test.tsx
Tests pending-component timing, root redirects, chained initial-load redirects, final navigation state, and absence of console errors.

Invalidation transition regression

Layer / File(s) Summary
Invalidate transition error handling
packages/react-router/tests/issue-7638-invalidate-transition-error.test.tsx
Tests invalidation failures from both loaders and render functions, repeated error rendering, hook-order crash prevention, and button interactivity.

Router core load regressions

Layer / File(s) Summary
Head execution after beforeLoad errors
packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts
Tests server and client loading, status 500, retained metadata, head invocation counts, and error-lane metadata.
Search normalization abort handling
packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts
Tests aborting the superseded load, completing canonical search normalization, avoiding surfaced abort errors, and producing successful defaulted search state.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: adding regression test coverage for existing router behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/already-fixed-router-issues

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

@nx-cloud

nx-cloud Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 09f0bf9

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 14m 28s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2m 19s View ↗

☁️ Nx Cloud last updated this comment at 2026-07-13 23:43:33 UTC

@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.

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: 967581ae7805
  • Measured at: 2026-07-13T23:30:16.607Z
  • Baseline source: history:58c005fcb1a0
  • Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 87.35 KiB 0 B (0.00%) 87.21 KiB 273.70 KiB 76.01 KiB ▁▁▁██████▄▄
react-router.full 91.06 KiB 0 B (0.00%) 90.92 KiB 285.59 KiB 79.19 KiB ▁▁▁██████▁▁
solid-router.minimal 35.53 KiB 0 B (0.00%) 35.40 KiB 105.90 KiB 31.94 KiB ▁▁▁██████▁▁
solid-router.full 40.58 KiB 0 B (0.00%) 40.46 KiB 121.11 KiB 36.51 KiB ▁▁▁██████▁▁
vue-router.minimal 53.00 KiB 0 B (0.00%) 52.87 KiB 149.94 KiB 47.63 KiB ▂▂▂██████▁▁
vue-router.full 58.94 KiB 0 B (0.00%) 58.81 KiB 168.70 KiB 52.76 KiB ▅▅▅██████▁▁
react-start.minimal 101.99 KiB 0 B (0.00%) 101.85 KiB 322.13 KiB 88.23 KiB ▁▁▄██████▄▄
react-start.deferred-hydration 102.72 KiB 0 B (0.00%) 101.87 KiB 323.50 KiB 88.88 KiB ▁▁▄██████▄▄
react-start.full 105.36 KiB 0 B (0.00%) 105.23 KiB 332.06 KiB 91.12 KiB ▁▁▄██████▁▁
react-start.rsbuild.minimal 99.68 KiB 0 B (0.00%) 99.51 KiB 316.57 KiB 85.74 KiB ▁▁▄██████▃▃
react-start.rsbuild.minimal-iife 100.08 KiB 0 B (0.00%) 99.91 KiB 317.51 KiB 86.11 KiB ▁▁▄██████▃▃
react-start.rsbuild.full 102.89 KiB 0 B (0.00%) 102.72 KiB 326.63 KiB 88.52 KiB ▁▁▄██████▂▂
solid-start.minimal 49.61 KiB 0 B (0.00%) 49.48 KiB 152.07 KiB 43.83 KiB ▃▃▅██████▁▁
solid-start.deferred-hydration 52.87 KiB 0 B (0.00%) 49.53 KiB 160.11 KiB 46.89 KiB ▃▃▅██████▁▁
solid-start.full 55.42 KiB 0 B (0.00%) 55.29 KiB 169.12 KiB 48.90 KiB ▃▃▆██████▁▁
vue-start.minimal 71.03 KiB 0 B (0.00%) 70.90 KiB 207.19 KiB 62.89 KiB ▄▄▇██████▁▁
vue-start.full 75.03 KiB 0 B (0.00%) 74.90 KiB 219.83 KiB 66.37 KiB ▃▃▅██████▁▁

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Jul 13, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@7812

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@7812

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@7812

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@7812

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@7812

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@7812

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@7812

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@7812

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@7812

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@7812

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@7812

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@7812

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@7812

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@7812

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@7812

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@7812

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@7812

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@7812

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@7812

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@7812

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@7812

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@7812

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@7812

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@7812

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@7812

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@7812

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@7812

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@7812

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@7812

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@7812

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@7812

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@7812

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@7812

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@7812

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@7812

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@7812

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@7812

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@7812

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@7812

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@7812

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@7812

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@7812

commit: 09f0bf9

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/react-router/tests/issue-7457-redirect-chain-first-load.test.tsx (1)

41-45: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Avoid any for the search updater parameter.

(prev: any) => ({ ...prev, flag: undefined }) bypasses type checking on the previous search shape. Since flag is typed as { flag?: boolean } via validateSearch, this can be typed explicitly (or left for inference) instead of any.

♻️ Proposed fix
-          search: (prev: any) => ({ ...prev, flag: undefined }),
+          search: (prev) => ({ ...prev, flag: undefined }),

As per coding guidelines, "Use TypeScript strict mode with extensive type safety" for **/*.{ts,tsx} files.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react-router/tests/issue-7457-redirect-chain-first-load.test.tsx`
around lines 41 - 45, Remove the explicit any annotation from the search updater
in the redirect call, allowing the parameter to be inferred or explicitly typed
as the validated search shape containing optional flag. Preserve the existing
spread and flag-clearing behavior.

Source: Coding guidelines

packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts (1)

19-21: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Preserve strict typing across these regression tests.

Both tests bypass router API contracts with any, reducing their ability to detect type and API regressions.

  • packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts#L19-L21: type the head callback context.
  • packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts#L60-L67: type the buildLocation options.
  • packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts#L74-L75: type the commitLocation payload.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts`
around lines 19 - 21, Replace the any-based types in the regression tests with
the appropriate router API types: type the failingHead callback context in
packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts (lines
19-21), the buildLocation options in
packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts
(lines 60-67), and the commitLocation payload there (lines 74-75). Preserve the
existing test behavior while ensuring these callbacks and method arguments are
checked against their actual contracts.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts`:
- Around line 76-84: Extend the client-lane assertions in the test around
rootMatch and failingMatch to verify rootMatch.links contains the retained
stylesheet link, matching the existing server-side coverage while preserving the
current metadata and error-status assertions.

In
`@packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts`:
- Around line 82-84: Replace the two waitForMacrotask calls in the aborted-load
test with a direct await of the aborted load’s rejection or an equivalent router
settlement signal, then assert the intermediate state only after that operation
completes; remove the timing-dependent event-loop sleeps while preserving the
existing assertions.

---

Nitpick comments:
In `@packages/react-router/tests/issue-7457-redirect-chain-first-load.test.tsx`:
- Around line 41-45: Remove the explicit any annotation from the search updater
in the redirect call, allowing the parameter to be inferred or explicitly typed
as the validated search shape containing optional flag. Preserve the existing
spread and flag-clearing behavior.

In `@packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts`:
- Around line 19-21: Replace the any-based types in the regression tests with
the appropriate router API types: type the failingHead callback context in
packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts (lines
19-21), the buildLocation options in
packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts
(lines 60-67), and the commitLocation payload there (lines 74-75). Preserve the
existing test behavior while ensuring these callbacks and method arguments are
checked against their actual contracts.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ae21b96-7907-4832-a3d3-14140a1b1342

📥 Commits

Reviewing files that changed from the base of the PR and between a41f265 and 09f0bf9.

📒 Files selected for processing (6)
  • packages/react-router/tests/issue-2182-root-pending.test.tsx
  • packages/react-router/tests/issue-7367-pending-min-redirect.test.tsx
  • packages/react-router/tests/issue-7457-redirect-chain-first-load.test.tsx
  • packages/react-router/tests/issue-7638-invalidate-transition-error.test.tsx
  • packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts
  • packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts

Comment on lines +76 to +84
const rootMatch = router.state.matches.find(
(match) => match.routeId === rootRoute.id,
)
const failingMatch = router.state.matches.find(
(match) => match.routeId === failingRoute.id,
)
expect(rootMatch?.meta).toEqual([{ title: 'Root title' }])
expect(failingMatch?.status).toBe('error')
expect(failingMatch?.meta).toEqual([{ title: 'Error title' }])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the referenced test and nearby related tests.
git ls-files 'packages/router-core/tests/*issue-4684*' 'packages/router-core/tests/*4684*' | sed 's#^`#FILE` #'

# Show the relevant portion of the client test with line numbers.
test_file='packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts'
if [ -f "$test_file" ]; then
  echo '--- CLIENT TEST ---'
  cat -n "$test_file" | sed -n '1,220p'
fi

# Search for the server-side links assertion in related tests.
echo '--- SEARCH links/meta in issue-4684 tests ---'
rg -n "links|meta|Root title|Error title|beforeload" packages/router-core/tests -S

Repository: TanStack/router

Length of output: 8928


🏁 Script executed:

#!/bin/bash
set -euo pipefail

test_file='packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts'
echo '--- EXISTS ---'
ls -l "$test_file"

echo '--- CLIENT TEST SNIPPET ---'
cat -n "$test_file" | sed -n '1,220p'

echo '--- SEARCH IN TEST DIR ---'
rg -n "links|meta|Root title|Error title|beforeload" packages/router-core/tests -S

Repository: TanStack/router

Length of output: 8976


🏁 Script executed:

#!/bin/bash
set -euo pipefail

test_file='packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts'
echo '--- CLIENT TEST ---'
cat -n "$test_file" | sed -n '1,220p'

echo '--- RELATED ASSERTIONS ---'
rg -n "rootMatch\.links|failingMatch\.links|Root title|Error title|beforeload" packages/router-core/tests -S

Repository: TanStack/router

Length of output: 4676


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find the code path that assembles head output into match state.
rg -n "links.*meta|meta.*links|head\\(|routeId.*links|statusCode|head content|links:" packages/router-core/src packages/router-core/tests -S

# Map likely files first.
for f in \
  packages/router-core/src/index.ts \
  packages/router-core/src/router.ts \
  packages/router-core/src/load.ts \
  packages/router-core/src/route.ts \
  packages/router-core/src/utils.ts
do
  if [ -f "$f" ]; then
    echo "--- OUTLINE $f ---"
    ast-grep outline "$f" --view expanded || true
  fi
done

Repository: TanStack/router

Length of output: 29701


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- router.ts around match initialization ---'
sed -n '1628,1660p' packages/router-core/src/router.ts | cat -n

echo '--- load-matches.ts around head/link fields ---'
sed -n '540,620p' packages/router-core/src/load-matches.ts | cat -n

echo '--- ssr-client.ts around head execution ---'
sed -n '150,210p' packages/router-core/src/ssr/ssr-client.ts | cat -n

Repository: TanStack/router

Length of output: 6756


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- find assignments to match.links / head output application ---'
rg -n "match\.links|links =|headScripts|executeHead\(|meta = headFnContent|styles =" packages/router-core/src -S

echo '--- load-matches.ts around where head results are consumed ---'
sed -n '620,760p' packages/router-core/src/load-matches.ts | cat -n

echo '--- maybe client-specific execution branches ---'
rg -n "isServer|isClient|ssr-client|executeHead" packages/router-core/src/load-matches.ts packages/router-core/src/ssr/ssr-client.ts -S

Repository: TanStack/router

Length of output: 7680


Assert rootMatch.links in the client lane too. The client path also hydrates head().links onto the match, so this test should cover the retained stylesheet like the server case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/router-core/tests/issue-4684-head-on-beforeload-error.test.ts`
around lines 76 - 84, Extend the client-lane assertions in the test around
rootMatch and failingMatch to verify rootMatch.links contains the retained
stylesheet link, matching the existing server-side coverage while preserving the
current metadata and error-status assertions.

Comment on lines +82 to +84
// Give the aborted rejection time to (incorrectly) commit as an error.
await waitForMacrotask()
await waitForMacrotask()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts"

printf '\n== outline ==\n'
ast-grep outline "$file" --view expanded || true

printf '\n== relevant lines ==\n'
nl -ba "$file" | sed -n '1,220p'

Repository: TanStack/router

Length of output: 341


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts"

echo "== file exists =="
test -f "$file" && echo yes

echo "== lines 1-220 =="
nl -ba "$file" | sed -n '1,220p'

Repository: TanStack/router

Length of output: 234


🏁 Script executed:

#!/bin/bash
set -euo pipefail
file="packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts"
nl -ba "$file" | sed -n '1,220p'

Repository: TanStack/router

Length of output: 193


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts"
if [ -f "$file" ]; then
  echo "FOUND"
  sed -n '1,220p' "$file" | nl -ba | sed -n '1,220p'
else
  echo "MISSING"
fi

Repository: TanStack/router

Length of output: 199


🏁 Script executed:

echo hi

Repository: TanStack/router

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts"

echo "== file slice =="
sed -n '1,220p' "$file" | cat -n

Repository: TanStack/router

Length of output: 5229


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts"

sed -n '1,220p' "$file" | cat -n

Repository: TanStack/router

Length of output: 5212


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n "waitForMacrotask|router.*settle|settlement|waitFor.*route|waitFor.*router|commitLocation" packages/router-core/tests packages/router-core/src -g '!**/dist/**'

Repository: TanStack/router

Length of output: 1555


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/src/router.ts"

sed -n '2140,2660p' "$file" | cat -n | sed -n '1,260p'

Repository: TanStack/router

Length of output: 9851


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="packages/router-core/src/router.ts"

sed -n '2580,2650p' "$file" | cat -n

Repository: TanStack/router

Length of output: 2636


Replace the macrotask sleeps with a direct await

Two setTimeout(0) turns are timing-dependent here; await the aborted load’s rejection or another router settlement signal instead of relying on event-loop timing before asserting the intermediate state.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/router-core/tests/issue-6371-search-default-normalization-abort.test.ts`
around lines 82 - 84, Replace the two waitForMacrotask calls in the aborted-load
test with a direct await of the aborted load’s rejection or an equivalent router
settlement signal, then assert the intermediate state only after that operation
completes; remove the timing-dependent event-loop sleeps while preserving the
existing assertions.

@codspeed-hq

codspeed-hq Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 12.86%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
❌ 4 (👁 4) regressed benchmarks
✅ 173 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths unmatched (react) 848.5 KB 477.6 KB +77.68%
Memory mem server error-paths redirect (solid) 918.1 KB 604 KB +52.01%
Simulation ssr streaming deferred (react) 73.1 ms 71 ms +3.03%
👁 Simulation ssr global-mw document (vue) 221.1 ms 233.7 ms -5.38%
👁 Simulation ssr head (solid) 190.6 ms 196.9 ms -3.22%
👁 Simulation client-loaders navigation loop (react) 52.8 ms 55.5 ms -4.94%
👁 Memory mem server error-paths not-found (react) 266.3 KB 276.5 KB -3.69%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing test/already-fixed-router-issues (09f0bf9) with main (a41f265)

Open in CodSpeed

@Sheraff Sheraff merged commit 11a6a0d into main Jul 13, 2026
26 checks passed
@Sheraff Sheraff deleted the test/already-fixed-router-issues branch July 13, 2026 23:44
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