Skip to content

Fix Bun server static routes from using the wrong path separator on Windows#5285

Merged
schiller-manuel merged 2 commits intoTanStack:mainfrom
nomoon:patch-1
Sep 28, 2025
Merged

Fix Bun server static routes from using the wrong path separator on Windows#5285
schiller-manuel merged 2 commits intoTanStack:mainfrom
nomoon:patch-1

Conversation

@nomoon
Copy link
Contributor

@nomoon nomoon commented Sep 28, 2025

The issue on Windows:

  • filepath will resolve to something like dist/client\assets\index-CYVUvHau.js, which is fine (Windows accepts either path separator and Bun will read the file just fine).
  • However, route will resolve into /assets\index-CYVUvHau.js, where the windows path separator \ won't match how the route will be requested over HTTP (/assets/index-CYVUvHau.js). So any static route with a path separator in it will fail to work.

To fix it, this change does 2 things:

  1. Fixes the route generation by normalizing all path separators into the expected POSIX /.
  2. Uses path.join() to create filepath. Not strictly necessary, but more correct (and we're importing node:path anyway for the first fix).

This should have no effect on any platform that already uses / as a path separator (though it is a little noisier).

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • Fixed inconsistent route generation across operating systems by normalizing file and URL paths, improving reliability on Windows, macOS, and Linux.
  • Refactor

    • Standardized path construction to a more robust approach, reducing edge cases and improving maintainability. No behavior or API changes expected.
  • Chores

    • Updated internal imports to use built-in modules. No configuration changes required.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 28, 2025

Walkthrough

Replaces manual string concatenation for file and route paths in examples/react/start-bun/server.ts with node:path utilities, using path.join and POSIX-style normalization. Adds an import for node:path. No changes to exported/public APIs or control flow.

Changes

Cohort / File(s) Summary
Path handling normalization
examples/react/start-bun/server.ts
Replace string-based path composition with path.join(clientDirectory, relativePath); normalize routes to POSIX-style by converting relativePath separators to /; add import path from 'node:path'; no exported/public API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit taps the keys with care,
Paths now join without a snare.
Slashes hop to POSIX lanes,
No more stringy, twisty chains.
With node:path snug in its burrow,
The routes all line up—straight and thorough! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the core change by stating that it fixes Bun server static routes and specifically addresses the Windows path separator bug, directly reflecting the PR’s intent and scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58e8a94 and c8f1913.

📒 Files selected for processing (1)
  • examples/react/start-bun/server.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript in strict mode with extensive type safety across the codebase

Files:

  • examples/react/start-bun/server.ts
examples/{react,solid}/**

📄 CodeRabbit inference engine (AGENTS.md)

Keep example applications under examples/react/ and examples/solid/

Files:

  • examples/react/start-bun/server.ts
🔇 Additional comments (1)
examples/react/start-bun/server.ts (1)

314-316: Windows separator normalization looks solid.

Using path.join for filepath and forcing route through POSIX separators eliminates the Windows mismatch without regressing POSIX platforms. Nice, focused fix.


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 and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Sep 28, 2025

View your CI Pipeline Execution ↗ for commit c8f1913

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

☁️ Nx Cloud last updated this comment at 2025-09-28 22:15:16 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 28, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5285

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5285

@tanstack/eslint-plugin-router

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

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5285

@tanstack/nitro-v2-vite-plugin

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

@tanstack/react-router

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

@tanstack/react-router-devtools

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

@tanstack/react-router-ssr-query

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

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5285

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5285

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5285

@tanstack/router-cli

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

@tanstack/router-core

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

@tanstack/router-devtools

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

@tanstack/router-devtools-core

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

@tanstack/router-generator

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

@tanstack/router-plugin

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

@tanstack/router-ssr-query-core

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

@tanstack/router-utils

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

@tanstack/router-vite-plugin

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

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5285

@tanstack/solid-router

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

@tanstack/solid-router-devtools

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

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5285

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5285

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5285

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5285

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5285

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5285

@tanstack/start-static-server-functions

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

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5285

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5285

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5285

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5285

commit: c8f1913

@schiller-manuel schiller-manuel merged commit 2817a0c into TanStack:main Sep 28, 2025
6 checks passed
naoya7076 pushed a commit to naoya7076/router that referenced this pull request Feb 15, 2026
…rator on Windows (TanStack#5285)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
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