Skip to content

fix(router-core): strip internal SSR globals from declarations - #8207

Draft
Sheraff wants to merge 4 commits into
mainfrom
chore/internal-ssr-window-globals
Draft

fix(router-core): strip internal SSR globals from declarations#8207
Sheraff wants to merge 4 commits into
mainfrom
chore/internal-ssr-window-globals

Conversation

@Sheraff

@Sheraff Sheraff commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • mark the SSR Window augmentation as internal
  • omit the complete augmentation from published declaration output
  • avoid exposing router and Seroval implementation globals to consumers

Testing

Not run; CI will validate the change.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T20:26:28.434464Z 88621b3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@nx-cloud

nx-cloud Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 94e3bf0

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

☁️ Nx Cloud last updated this comment at 2026-08-31 21:09:15 UTC

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

4 package(s) bumped directly, 10 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/react-router 1.170.32 → 1.170.33 Changeset
@tanstack/solid-router 1.170.30 → 1.170.31 Changeset
@tanstack/start-plugin-core 1.171.39 → 1.171.40 Changeset
@tanstack/vue-router 1.170.29 → 1.170.30 Changeset
@tanstack/react-start 1.168.49 → 1.168.50 Dependent
@tanstack/react-start-client 1.168.30 → 1.168.31 Dependent
@tanstack/react-start-rsc 0.1.48 → 0.1.49 Dependent
@tanstack/react-start-server 1.167.37 → 1.167.38 Dependent
@tanstack/solid-start 1.168.47 → 1.168.48 Dependent
@tanstack/solid-start-client 1.168.29 → 1.168.30 Dependent
@tanstack/solid-start-server 1.167.36 → 1.167.37 Dependent
@tanstack/vue-start 1.168.46 → 1.168.47 Dependent
@tanstack/vue-start-client 1.167.32 → 1.167.33 Dependent
@tanstack/vue-start-server 1.167.36 → 1.167.37 Dependent

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 04167db4-1d8c-4de7-aaeb-0c7ea46e4418

📥 Commits

Reviewing files that changed from the base of the PR and between 37877da and 88621b3.

📒 Files selected for processing (1)
  • packages/router-core/src/load-client.ts

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


📝 Walkthrough

Walkthrough

The change adds an @internal JSDoc annotation above the global SSR hydration declarations. It does not change runtime behavior or exported entities.

Changes

SSR hydration declarations

Layer / File(s) Summary
Mark SSR hydration declarations as internal
packages/router-core/src/load-client.ts
Adds an @internal JSDoc annotation above the declare global block for SSR hydration globals.

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

Merge Risk: ⚪ Minimal · up to 88621

This localized declaration-only change hides internal SSR globals from published types without changing runtime behavior, and no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: schiller-manuel

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change and testing status, but it does not use the required Changes, Checklist, and Release Impact sections. It also omits the required checklist items and release-impact … Rewrite the description to include the required ## 🎯 Changes, ## ✅ Checklist, and ## 🚀 Release Impact sections. Describe the change under Changes, complete each checklist item, and select the appropriate release-impact option. If this chang…
✅ Passed checks (4 passed)
Check name Status Explanation
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 1…
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.
Title check ✅ Passed The title clearly describes the main change: marking internal SSR globals so they are omitted from published declarations.
Full details: Docstring Coverage

Explanation

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 1 files.

Full details: Description check

Explanation

The description explains the change and testing status, but it does not use the required Changes, Checklist, and Release Impact sections. It also omits the required checklist items and release-impact selection.

Resolution

Rewrite the description to include the required ## 🎯 Changes, ## ✅ Checklist, and ## 🚀 Release Impact sections. Describe the change under Changes, complete each checklist item, and select the appropriate release-impact option. If this change affects published code, add a changeset.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/internal-ssr-window-globals

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88621b3cd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/router-core/src/load-client.ts Outdated

// --- SSR hydration (client entry via @tanstack/router-core/ssr/client) ---

/** @internal */

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a router-core changeset

This changes the published declaration output of @tanstack/router-core, but the commit adds no .changeset entry. Because the release workflow versions and publishes packages selected by changesets, this fix will not independently trigger a router-core release or appear in its changelog; add a patch changeset for the package as required by the repository's contribution workflow.

AGENTS.md reference: AGENTS.md:L3-L5

Useful? React with 👍 / 👎.

@Sheraff
Sheraff marked this pull request as draft August 31, 2026 20:26
@Sheraff Sheraff changed the title fix(router-core): strip internal SSR globals from declarations fix(router-core): avoid stripped SSR type reference Aug 31, 2026
@Sheraff Sheraff changed the title fix(router-core): avoid stripped SSR type reference fix(router-core): strip internal SSR globals from declarations Aug 31, 2026
nx-cloud[bot]

This comment was marked as outdated.

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

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We add a local /** @internal */ declare global { interface Window { $_TSR?: TsrSsrGlobal } } block to each framework's RouterClient.tsx and to solid-router's setupTests.tsx to fix the downstream TS2339 build failures. The PR marked the Window augmentation in router-core as @internal, which caused it to be stripped from the published declarations by stripInternal, removing $_TSR from the Window type for all consumers. By re-declaring the augmentation locally—also marked @internal—the internal SSR files retain correct types without exposing the global in any package's published declarations.

Tip

We verified this fix by re-running @tanstack/vue-router:build, @tanstack/react-router:build, @tanstack/solid-router:build and 1 more.

Suggested Fix changes
diff --git a/packages/react-router/src/ssr/RouterClient.tsx b/packages/react-router/src/ssr/RouterClient.tsx
index 69abc97f..7d8a3800 100644
--- a/packages/react-router/src/ssr/RouterClient.tsx
+++ b/packages/react-router/src/ssr/RouterClient.tsx
@@ -1,8 +1,15 @@
-import { hydrate } from '@tanstack/router-core/ssr/client'
+import { hydrate, type TsrSsrGlobal } from '@tanstack/router-core/ssr/client'
 import { Await } from '../awaited'
 import { RouterProvider } from '../RouterProvider'
 import type { AnyRouter } from '@tanstack/router-core'
 
+/** @internal */
+declare global {
+  interface Window {
+    $_TSR?: TsrSsrGlobal
+  }
+}
+
 let hydrationPromise: Promise<void> | undefined
 
 export function RouterClient(props: { router: AnyRouter }) {
diff --git a/packages/solid-router/src/ssr/RouterClient.tsx b/packages/solid-router/src/ssr/RouterClient.tsx
index c2389495..a8028e23 100644
--- a/packages/solid-router/src/ssr/RouterClient.tsx
+++ b/packages/solid-router/src/ssr/RouterClient.tsx
@@ -1,10 +1,17 @@
-import { hydrate } from '@tanstack/router-core/ssr/client'
+import { hydrate, type TsrSsrGlobal } from '@tanstack/router-core/ssr/client'
 import { Await } from '../awaited'
 import { HeadContent } from '../HeadContent'
 import { RouterProvider } from '../RouterProvider'
 import type { AnyRouter } from '@tanstack/router-core'
 import type { JSXElement } from 'solid-js'
 
+/** @internal */
+declare global {
+  interface Window {
+    $_TSR?: TsrSsrGlobal
+  }
+}
+
 let hydrationPromise: Promise<void> | undefined
 
 const Dummy = (props: { children?: JSXElement }) => <>{props.children}</>
diff --git a/packages/solid-router/tests/setupTests.tsx b/packages/solid-router/tests/setupTests.tsx
index c3d7ec5c..4bee6624 100644
--- a/packages/solid-router/tests/setupTests.tsx
+++ b/packages/solid-router/tests/setupTests.tsx
@@ -1,5 +1,12 @@
 import '@testing-library/jest-dom/vitest'
 import { vi } from 'vitest'
+import type { TsrSsrGlobal } from '@tanstack/router-core/ssr/client'
+
+declare global {
+  interface Window {
+    $_TSR?: TsrSsrGlobal
+  }
+}
 
 // @ts-expect-error
 global.IS_REACT_ACT_ENVIRONMENT = true
diff --git a/packages/vue-router/src/ssr/RouterClient.tsx b/packages/vue-router/src/ssr/RouterClient.tsx
index b21f0fc9..d8c48f18 100644
--- a/packages/vue-router/src/ssr/RouterClient.tsx
+++ b/packages/vue-router/src/ssr/RouterClient.tsx
@@ -3,6 +3,14 @@ import { hydrate } from '@tanstack/router-core/ssr/client'
 import { HeadContent } from '../HeadContent'
 import { RouterProvider } from '../RouterProvider'
 import type { AnyRouter } from '@tanstack/router-core'
+import type { TsrSsrGlobal } from '@tanstack/router-core/ssr/client'
+
+/** @internal */
+declare global {
+  interface Window {
+    $_TSR?: TsrSsrGlobal
+  }
+}
 
 let hydrationPromise: Promise<void> | undefined
 

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally 3eNU-m32g

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

@codspeed-hq

codspeed-hq Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.17%

⚠️ 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

⚡ 8 improved benchmarks
❌ 8 regressed benchmarks
✅ 164 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Memory mem server error-paths redirect (solid) 368.7 KB 916.8 KB -59.79%
Memory mem client unique-location-churn (vue) 475.7 KB 971.8 KB -51.05%
Memory mem server serialization-payload (react) 4.2 MB 6 MB -30.34%
Memory mem server aborted-requests (solid) 1.2 MB 1.3 MB -5.61%
Simulation client-async-pipeline navigation loop (react) 61.9 ms 65 ms -4.84%
Memory mem server error-paths unmatched (react) 441.5 KB 460.5 KB -4.12%
Memory mem server error-paths unmatched (vue) 577.5 KB 600.2 KB -3.79%
Memory mem server request-churn (react) 639.3 KB 660.4 KB -3.19%
Memory mem server error-paths redirect (vue) 891.9 KB 501.6 KB +77.83%
Memory mem server error-paths not-found (solid) 698.7 KB 555.3 KB +25.83%
Memory mem client preload-churn (vue) 919.3 KB 760.5 KB +20.89%
Memory mem client navigation-churn (vue) 1.7 MB 1.5 MB +11.11%
Simulation client-nested-params navigation loop (react) 151.2 ms 137 ms +10.37%
Memory mem server error-paths redirect (react) 315.9 KB 292.3 KB +8.07%
Simulation ssr global-mw document (solid) 366.2 ms 349.3 ms +4.83%
Simulation ssr server-fn multipart (solid) 144.3 ms 139.6 ms +3.4%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing chore/internal-ssr-window-globals (94e3bf0) with main (37877da)

Open in CodSpeed

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

This pull request does not affect bundle size in any measured scenario.

@pkg-pr-new

pkg-pr-new Bot commented Aug 31, 2026

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

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

@tanstack/eslint-plugin-router

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

@tanstack/eslint-plugin-start

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

@tanstack/history

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

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

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

@tanstack/react-start-client

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

@tanstack/react-start-rsc

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

@tanstack/react-start-server

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

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-router-ssr-query

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

@tanstack/solid-start

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

@tanstack/solid-start-client

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

@tanstack/solid-start-server

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

@tanstack/start-client-core

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

@tanstack/start-fn-stubs

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

@tanstack/start-plugin-core

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

@tanstack/start-server-core

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

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

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

@tanstack/valibot-adapter

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

@tanstack/virtual-file-routes

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

@tanstack/vue-router

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

@tanstack/vue-router-devtools

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

@tanstack/vue-router-ssr-query

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

@tanstack/vue-start

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

@tanstack/vue-start-client

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

@tanstack/vue-start-server

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

@tanstack/zod-adapter

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

commit: 94e3bf0

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