[PR #8115] [MERGED] fix(dev): read PORT from .env in the dev launcher health check #8109

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8115
Author: @ylli-selmani
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @ylli-selmani

Base: staging ← Head: fix/dev-health-env-port


📝 Commits (1)

  • eda5747 fix(dev): read PORT from .env in the dev launcher health check

📊 Changes

2 files changed (+59 additions, -8 deletions)

View changed files

📝 scripts/dev.mjs (+24 -1)
📝 scripts/regressions/dev-launcher-process.regression.mjs (+35 -7)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

No issue yet; follow-up to #8111, which fixed the same gap for the Vite dev proxy. One should be opened if a maintainer wants it tracked separately.

Why this change

  • pnpm dev runs scripts/dev.mjs, which read PORT only from the environment and defaulted to 7860. The server reads PORT from the root .env. With PORT set only in .env (the normal setup), the launcher's health check polled 7860 instead.
  • If another Marinara install was running on 7860, the launcher found it healthy, printed "already running … Reusing it", never started this checkout's server, and the client then talked to the wrong instance. With nothing on 7860, it started the server on the .env port but waited on 7860 until the ready timeout.
  • #8111 made Vite read .env itself; this closes the same gap one level up, so pnpm dev no longer needs PORT exported in the shell.

What changed

  • scripts/dev.mjs: the port resolves the way the server's getPort() does: an exported PORT wins (dotenv never overrides it), otherwise PORT from the server's .env file (MARINARA_ENV_FILE if set, else the root .env), parsed with Number.parseInt, falling back to 7860. It reuses scripts/read-launcher-env.mjs, a sibling of dev.mjs, so no new file has to exist where the launcher runs.
  • The launcher exports the resolved PORT, so the server and the Vite child process use the same port the health check polls.
  • scripts/regressions/dev-launcher-process.regression.mjs: the fixture now mirrors the repo layout (scripts/ one level below the .env), and a new case launches with PORT unexported and only in the fixture's .env.

Known limit: the port is fixed when pnpm dev starts. Changing PORT in .env while it runs needs a pnpm dev restart, as it did before for the health check (and PORT is restart-required in the server too).

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

Agent-side checks (not a substitute for the boxes above): pnpm check exit 0. node scripts/run-regressions.mjs --filter dev-launcher-process: 1/1 passed. Mutation controls, each run once with dev.mjs temporarily edited and restored after: ignoring .env → the new case fails ("Launcher did not start its server on the PORT from .env"); not exporting PORT to the children → it fails the same way. Local CodeRabbit (--committed --base origin/staging): 0 findings.

Manual verification notes

  • Manually verify: with PORT=<not 7860> only in the root .env (not exported) and another Marinara instance on 7860, run pnpm dev; the log should say Waiting for server at http://127.0.0.1:<that port>/api/health, this checkout's server should start, and the browser should load this checkout's data with no build-skew banner.
  • Manually verify: with PORT exported in the shell, the exported value still wins over .env.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No user docs tell people to export PORT for pnpm dev, so none were changed.

UI evidence (if applicable)

Not a UI change.

🤖 Generated with Claude Code


🔄 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/8115 **Author:** [@ylli-selmani](https://github.com/ylli-selmani) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@ylli-selmani](https://github.com/ylli-selmani) **Base:** `staging` ← **Head:** `fix/dev-health-env-port` --- ### 📝 Commits (1) - [`eda5747`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eda57477f88e8c94491930fde5ef04902b8fc82b) fix(dev): read PORT from .env in the dev launcher health check ### 📊 Changes **2 files changed** (+59 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `scripts/dev.mjs` (+24 -1) 📝 `scripts/regressions/dev-launcher-process.regression.mjs` (+35 -7) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue No issue yet; follow-up to #8111, which fixed the same gap for the Vite dev proxy. One should be opened if a maintainer wants it tracked separately. ## Why this change - `pnpm dev` runs `scripts/dev.mjs`, which read `PORT` only from the environment and defaulted to 7860. The server reads `PORT` from the root `.env`. With `PORT` set only in `.env` (the normal setup), the launcher's health check polled 7860 instead. - If another Marinara install was running on 7860, the launcher found it healthy, printed "already running … Reusing it", never started this checkout's server, and the client then talked to the wrong instance. With nothing on 7860, it started the server on the `.env` port but waited on 7860 until the ready timeout. - #8111 made Vite read `.env` itself; this closes the same gap one level up, so `pnpm dev` no longer needs `PORT` exported in the shell. ## What changed - `scripts/dev.mjs`: the port resolves the way the server's `getPort()` does: an exported `PORT` wins (dotenv never overrides it), otherwise `PORT` from the server's `.env` file (`MARINARA_ENV_FILE` if set, else the root `.env`), parsed with `Number.parseInt`, falling back to 7860. It reuses `scripts/read-launcher-env.mjs`, a sibling of `dev.mjs`, so no new file has to exist where the launcher runs. - The launcher exports the resolved `PORT`, so the server and the Vite child process use the same port the health check polls. - `scripts/regressions/dev-launcher-process.regression.mjs`: the fixture now mirrors the repo layout (`scripts/` one level below the `.env`), and a new case launches with `PORT` unexported and only in the fixture's `.env`. Known limit: the port is fixed when `pnpm dev` starts. Changing `PORT` in `.env` while it runs needs a `pnpm dev` restart, as it did before for the health check (and `PORT` is restart-required in the server too). ## 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` Agent-side checks (not a substitute for the boxes above): `pnpm check` exit 0. `node scripts/run-regressions.mjs --filter dev-launcher-process`: 1/1 passed. Mutation controls, each run once with `dev.mjs` temporarily edited and restored after: ignoring `.env` → the new case fails ("Launcher did not start its server on the PORT from .env"); not exporting `PORT` to the children → it fails the same way. Local CodeRabbit (`--committed --base origin/staging`): 0 findings. ### Manual verification notes - Manually verify: with `PORT=<not 7860>` only in the root `.env` (not exported) and another Marinara instance on 7860, run `pnpm dev`; the log should say `Waiting for server at http://127.0.0.1:<that port>/api/health`, this checkout's server should start, and the browser should load this checkout's data with no build-skew banner. - Manually verify: with `PORT` exported in the shell, the exported value still wins over `.env`. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No user docs tell people to export `PORT` for `pnpm dev`, so none were changed. ## UI evidence (if applicable) Not a UI change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:10:28 +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#8109
No description provided.