fix(dev): pin turbopack root and randomize the dev server port - #11
Merged
Merged
Conversation
A sibling lockfile above or beside the project (a stray one in the home directory, or another worktree under .claude/worktrees/* carrying its own pnpm-lock.yaml) makes Next.js infer the wrong workspace root and print the warning on every dev server start. Pinning turbopack.root explicitly removes the inference. Fixes #10 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
next dev already reads the PORT env var natively, so dropping the -p flag
entirely lets Next fall back to its own 3000-and-increment behavior for
plain `pnpm dev`, while `.claude/launch.json`'s `autoPort: true` can assign
a genuinely free port by setting PORT before spawning it — that only works
when nothing hardcodes `-p`, which the previous `-p ${PORT:-3000}` did.
Moves the E2E server (a separate `next start` instance, unrelated to `pnpm
dev`) off 3000 too, since that's the port most likely to already be held by
someone's dev server. playwright.config.ts is the single source for it now;
CI's redundant PLAYWRIGHT_BASE_URL override is dropped so it can't drift.
Co-Authored-By: Claude Sonnet 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.
Summary
turbopack.rootinnext.config.tsso Next.js stops inferring the workspace root from sibling lockfiles (a stray one in the home dir, or another worktree under.claude/worktrees/*), which fired the "inferred your workspace root" warning on everypnpm dev.devscript's-pflag entirely (next dev --turbopack, no port arg).next devalready readsPORTfrom the environment natively, so:pnpm devfalls back to Next's own 3000-and-increment behavior.PORT=3010 pnpm devstill forces a specific port..claude/launch.json'sautoPort: true(added here) can assign a genuinely free port itself and hand it in viaPORT— this only works when the script doesn't hardcode-p, which the previous-p ${PORT:-3000}did.playwright.config.ts'sPORT→ 3417). That's a separatenext startinstance (pnpm test:e2e→pnpm build && pnpm start), unrelated topnpm dev, but 3000 is the port most likely to already be held by someone's dev server.playwright.config.tsis now the single source for that port — dropped CI's redundantPLAYWRIGHT_BASE_URLoverride so it can't drift out of sync.Why not
-p 0?The issue originally proposed
next dev --turbopack -p 0(OS-assigned random port). I tried that first, but it breaks.claude/launch.json'sautoPortintegration:autoPortworks by picking a free port itself and injecting it via thePORTenv var when spawning the dev command — a hardcoded-p 0overrides that and the two disagree about which port the server is actually on. Dropping-pentirely (confirmednext devreadsPORTon its own) is what makes both paths — manual andautoPort-driven — agree.Test plan
pnpm type-check,pnpm lint,pnpm format:check,pnpm test(pre-push hook, all green)pnpm devno longer prints the workspace-root inference warning, verified with sibling worktree lockfiles presentPORT=4321 next dev --turbopackbinds to exactly 4321 with no-pflag present, confirming the env-var pathautoPortrelies onPORT=3417 next startbinds to exactly 3417 the same waypnpm build && pnpm exec playwright test --project=chromium— all 4 E2E specs pass against the server on port 3417🤖 Generated with Claude Code