fix(editor): use a literal dev port so bun dev works on Windows - #551
Open
evolv3ai wants to merge 2 commits into
Open
fix(editor): use a literal dev port so bun dev works on Windows#551evolv3ai wants to merge 2 commits into
bun dev works on Windows#551evolv3ai wants to merge 2 commits into
Conversation
On Windows, `bun run` executes package scripts with Bun's own built-in
shell rather than a POSIX shell. That shell does not implement
default-value parameter expansion, so `${PORT:-3002}` is passed through
to Next.js verbatim and the dev server exits immediately:
error: option '-p, --port <port>' argument '${PORT:-3002}' is invalid.
'${PORT:-3002}' is not a non-negative number.
Setting PORT in the environment does not help — the literal is never
expanded either way.
Replace the expansion with the documented default port (3002).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The scene store hands out `/editor/<id>` as a project's canonical URL (`editorUrlForScene` in packages/mcp/src/storage/sqlite-scene-store.ts) and `/api/scenes` reports it verbatim, but this app only routes `/scene/[id]`. Every MCP-reported `editorUrl` therefore 404s. Rewrite `/editor/:id` to `/scene/:id` rather than redirect: client code parses the project id back out of the browser path (scan upload in packages/editor/src/components/ui/action-menu/view-toggles.tsx), so the `/editor/` prefix has to survive the hop. `/scene/<id>` keeps working for the app's own links, and the MCP-side tests asserting `/editor/<id>` stay valid, so no test or storage changes are needed. Also pass `--hostname 0.0.0.0` explicitly to `next dev`. Next already binds every interface by default, so this pins that behaviour rather than changing it, and surfaces the Network URL in dev output. Reaching the dev server from another device still requires an inbound firewall rule for port 3002. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bun devfails immediately on Windows. Theeditordev task dies before Next.js starts:Cause
On Windows,
bun runexecutes package scripts with Bun's own built-in shell rather than handing them to a POSIX shell. That shell does not implement default-value parameter expansion, so${PORT:-3002}inapps/editor/package.jsonreaches Next.js verbatim and is rejected.Setting
PORTin the environment first does not work around it — the literal is never expanded either way. There is no shell-level workaround from the caller's side; the script itself has to avoid the syntax.Fix
Use the documented default port directly:
Verified on Windows 11 / Bun 1.3.6 / Node 24.18.0 —
bun devnow boots the whole workspace and the editor servesHTTP 200on http://localhost:3002.Tradeoff, and an alternative if you'd prefer it
This drops the
PORToverride that SETUP.md documents. I kept the change to one line because that's the smallest thing that unblocks Windows, but I'm happy to switch to a small cross-platform launcher instead, which would preservePORTon every platform:Just say which you'd rather have and I'll update the PR.
Two unrelated things I noticed while debugging
Not touched in this PR, but worth flagging:
The root
devscript is also a no-op on Windows. It begins withset -a && . ./.env 2>/dev/null; set +a; turbo run dev --env-mode=loose. Bun's shell has nosetbuiltin, so it printsbun: command not found: settwice and silently skips loading.env. Turbo still runs, so it's non-fatal, but any variables in a root.envare never loaded on Windows..env.exampleandSETUP.mddisagree on the default port..env.examplesays# Dev server port (default: 3000)/# PORT=3000, while SETUP.md and the dev script both use 3002.Note
Low Risk
Routing and local dev ergonomics only; no auth, data, or production runtime behavior beyond serving the correct editor path.
Overview
MCP and hosted links use
/editor/<id>, but this app’s page lives at/scene/[id], so those URLs 404 locally. A Next.js rewrite maps/editor/:id→/scene/:idwithout changing the browser path, which matters because client code (e.g. scan upload inview-toggles.tsx) parses the project id from/editor/....The
devscript now runsnext devon port3002with a literal port (no${PORT:-3002}) sobun devworks on Windows, and adds--hostname 0.0.0.0so the dev server is reachable beyond localhost.Reviewed by Cursor Bugbot for commit 76add12. Bugbot is set up for automated code reviews on this repo. Configure here.