[PR #892] [MERGED] Fix startup port collision handling #4825

Closed
opened 2026-10-22 04:10:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/892
Author: @cha1latte
Created: 5/15/2026
Status: ✅ Merged
Merged: 5/15/2026
Merged by: @cha1latte

Base: staging ← Head: fix/issue-890-port-collision


📝 Commits (1)

  • 0908af5 fix startup port collision handling

📊 Changes

4 files changed (+67 additions, -1 deletions)

View changed files

📝 packages/server/src/index.ts (+13 -1)
➕ scripts/check-port-available.mjs (+44 -0)
📝 start.bat (+6 -0)
📝 start.sh (+4 -0)

📄 Description

Linked issue

Closes #890

Why this change

  • Marinara defaults to port 7860, which is also a common local image-generation port. When that port is already occupied, startup previously fell through to a raw EADDRINUSE path, and the launch scripts could still schedule the browser open before confirming Marinara had bound the port.

What changed

  • Added a shared launcher preflight script that checks whether the configured PORT is available before the browser-open step runs.
  • Wired the preflight into start.sh and start.bat so occupied ports print a clear recovery message instead of opening the browser to another local service.
  • Added a clearer direct-server EADDRINUSE log message for users who bypass the launch scripts.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Codex reproduced the pre-fix failure with scratch/issue-890-port-repro.mjs --expect=before, which binds 7860 first and then starts the Marinara server path. Before the fix, startup exited with raw EADDRINUSE and no recovery hint.
  • Codex verified the fixed direct-server path with scratch/issue-890-port-repro.mjs --expect=after --out=scratch/issue-890-after-server.txt; it now prints a clear "Port 7860 is already in use" recovery message.
  • Codex verified the fixed launcher preflight with scratch/issue-890-port-repro.mjs --expect=after --target=preflight --out=scratch/issue-890-after-preflight.txt; it exits before the banner/browser-open step and tells the user how to choose another port.
  • Codex checked edge cases: free default port exits cleanly, occupied alternate port 7869 gets the same recovery message, and invalid PORT exits with a numeric range error.
  • pnpm check passed locally in the issue worktree.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or version files changed. This PR intentionally does not change Marinara's canonical default port; it only makes occupied-port startup truthful and recoverable.

UI evidence (if applicable)

Not applicable; this is command/startup behavior. Codex captured visual proof of the command output locally at scratch/issue-890-after-preflight.png.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/892 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/15/2026 **Status:** ✅ Merged **Merged:** 5/15/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `staging` ← **Head:** `fix/issue-890-port-collision` --- ### 📝 Commits (1) - [`0908af5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0908af50919d1739a17f122bf047252c0add7692) fix startup port collision handling ### 📊 Changes **4 files changed** (+67 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/index.ts` (+13 -1) ➕ `scripts/check-port-available.mjs` (+44 -0) 📝 `start.bat` (+6 -0) 📝 `start.sh` (+4 -0) </details> ### 📄 Description ## Linked issue Closes #890 ## Why this change - Marinara defaults to port `7860`, which is also a common local image-generation port. When that port is already occupied, startup previously fell through to a raw `EADDRINUSE` path, and the launch scripts could still schedule the browser open before confirming Marinara had bound the port. ## What changed - Added a shared launcher preflight script that checks whether the configured `PORT` is available before the browser-open step runs. - Wired the preflight into `start.sh` and `start.bat` so occupied ports print a clear recovery message instead of opening the browser to another local service. - Added a clearer direct-server `EADDRINUSE` log message for users who bypass the launch scripts. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Codex reproduced the pre-fix failure with `scratch/issue-890-port-repro.mjs --expect=before`, which binds `7860` first and then starts the Marinara server path. Before the fix, startup exited with raw `EADDRINUSE` and no recovery hint. - Codex verified the fixed direct-server path with `scratch/issue-890-port-repro.mjs --expect=after --out=scratch/issue-890-after-server.txt`; it now prints a clear "Port 7860 is already in use" recovery message. - Codex verified the fixed launcher preflight with `scratch/issue-890-port-repro.mjs --expect=after --target=preflight --out=scratch/issue-890-after-preflight.txt`; it exits before the banner/browser-open step and tells the user how to choose another port. - Codex checked edge cases: free default port exits cleanly, occupied alternate port `7869` gets the same recovery message, and invalid `PORT` exits with a numeric range error. - `pnpm check` passed locally in the issue worktree. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or version files changed. This PR intentionally does not change Marinara's canonical default port; it only makes occupied-port startup truthful and recoverable. ## UI evidence (if applicable) Not applicable; this is command/startup behavior. Codex captured visual proof of the command output locally at `scratch/issue-890-after-preflight.png`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:58 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4825
No description provided.