Skip to content

Auto-select next available dev ports by mode and remove favicon fallback#140

Merged
juliusmarminge merged 2 commits intomainfrom
t3code/auto-increment-web-dev-port
Mar 2, 2026
Merged

Auto-select next available dev ports by mode and remove favicon fallback#140
juliusmarminge merged 2 commits intomainfrom
t3code/auto-increment-web-dev-port

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Mar 2, 2026

Summary

  • add dynamic dev-port selection in scripts/dev-runner.mjs so dev, dev:web, and dev:server each pick the next available offset based on required ports
  • add loopback port-availability checks (IPv4/IPv6), computed-port validation, and clearer startup logging for selected offsets
  • add unit coverage for findFirstAvailableOffset and resolveModePortOffsets in scripts/dev-runner.test.ts
  • remove project favicon SVG fallback behavior; /api/project-favicon now returns 404 when no icon is found, and remove the related fallback test
  • simplify a few server/web callsites (schema serialization path, detached upstream refresh, minor sidebar class/formatting adjustments)

Testing

  • scripts/dev-runner.test.ts: validates offset scanning, mode-specific offset behavior, and explicit override handling
  • apps/server/src/projectFaviconRoute.test.ts: fallback favicon test removed to match new 404 behavior
  • bun lint: Not run
  • bun typecheck: Not run

Note

Medium Risk
Changes dev startup behavior by introducing async port probing and mode-specific offset selection, which could alter how local environments pick/bind ports (especially across IPv4/IPv6). Test coverage is added, but failures could still surface on unusual network/loopback configurations.

Overview
The dev runner now auto-selects the next available port offset by probing loopback availability and applying mode-specific requirements: dev finds a shared offset for server+web, dev:web shifts only the web port, and dev:server shifts only the server port (unless explicit T3CODE_PORT/VITE_DEV_SERVER_URL overrides are provided).

It also sets PORT/ELECTRON_RENDERER_PORT/VITE_DEV_SERVER_URL when missing, validates computed ports are within 1..65535, improves startup logging to show selected offsets, and switches the entrypoint to async error handling. New unit tests cover offset scanning and override/mode behaviors.

Written by Cursor Bugbot for commit 70248fa. This will update automatically on new commits. Configure here.

Note

Auto-select next available dev ports by mode and validate against 1–65535 in scripts/dev-runner.mjs

Add async port probing on IPv4/IPv6, scan offsets to pick mode-aware server/web ports, and set PORT, ELECTRON_RENDERER_PORT, and VITE_DEV_SERVER_URL when not provided in dev-runner.mjs.

📍Where to Start

Start with resolveModePortOffsets and runDevRunner in dev-runner.mjs.

Macroscope summarized 70248fa.

- Probe localhost ports and increment offsets when base ports are taken
- Resolve server/web offsets by mode while honoring explicit port/dev-url overrides
- Add tests for offset selection and per-mode fallback behavior
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 2, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch t3code/auto-increment-web-dev-port

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread scripts/dev-runner.mjs Outdated
- Stop `findFirstAvailableOffset` only when a required port exceeds `MAX_PORT`
- Add test covering offsets where only non-required ports are out of range
@juliusmarminge juliusmarminge merged commit 9f06835 into main Mar 2, 2026
4 checks passed
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.

1 participant