Skip to content

server: fix Server.url for Windows Unix socket paths - #40307

Closed
mmustafasenoglu wants to merge 1 commit into
oven-sh:mainfrom
mmustafasenoglu:fix-server-url-40182
Closed

mmustafasenoglu wants to merge 1 commit into
oven-sh:mainfrom
mmustafasenoglu:fix-server-url-40182

Conversation

@mmustafasenoglu

Copy link
Copy Markdown

Fixes #40182

Summary

When using Bun.serve with unix path on Windows, the server.url property returned an invalid URL because Windows paths contain backslashes and colons.

Changes

  • Modified get_url_as_string() in src/runtime/server/mod.rs to convert backslashes to forward slashes on Windows for Unix socket paths.
  • This produces valid URLs like unix://C:/test instead of unix://C:\test.

Testing

  • This change is Windows-specific (guarded by cfg(windows))
  • Existing tests on Linux/macOS should be unaffected

Convert backslashes to forward slashes in Unix socket paths on Windows
to produce valid URLs. Previously, paths like 'C:\test' would produce
'unix://C:\test' which is an invalid URL due to backslashes and colon.

Fixes: #40182
Copilot AI lite review requested due to automatic review settings August 24, 2026 09:28

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2f9707e3-7271-4042-a70f-ef53a2f6206b

📥 Commits

Reviewing files that changed from the base of the PR and between f2fe7d3 and 57de88a.

📒 Files selected for processing (1)
  • src/runtime/server/mod.rs

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


Walkthrough

NewServer::get_url_as_string now normalizes Windows Unix socket paths before URL construction. Non-Windows behavior continues to copy raw Unix path bytes.

Changes

Unix socket URL generation

Layer / File(s) Summary
Normalize socket paths for URL construction
src/runtime/server/mod.rs
Windows paths use replacement UTF-8 decoding and forward slashes. Non-Windows paths retain their raw bytes.

Suggested reviewers: robobun, jarred-sumner, dylan-conway

Merge Risk: ⚪ Minimal · up to 57de8

This localized Windows URL formatting change has no actionable merge-blocking risk remaining and is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Windows-specific Server.url fix for Unix socket paths.
Description check ✅ Passed The description explains the bug, implementation, expected behavior, and testing impact, despite using different headings from the template.
Linked Issues check ✅ Passed The change addresses issue #40182 by producing valid Windows Unix socket URLs with forward slashes.
Out of Scope Changes check ✅ Passed The changes are limited to Windows Unix socket URL generation and related cross-platform behavior.

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.

@robobun

robobun commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix, @mmustafasenoglu, and for tracking down the cause. #35806 (opened earlier) fixes the same server.url failure at the same spot. It percent-encodes the socket path in URLFormatter instead of replacing the backslashes. So the URL also parses for paths with spaces or other special bytes, and the change applies on every platform, not only Windows. It now carries a test for the C:\test case from #40182 and will close that issue when it merges.

Closing this one in favor of #35806.

@robobun robobun closed this Aug 24, 2026
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.

Bun.Server.url can return invalid url in windows

3 participants