Skip to content

chore(build): re-apply build-reorg follow-ups (compat fallback + deploy docs) - #3127

Merged
diegosouzapw merged 3 commits into
release/v3.8.9from
chore/build-reorg-followups
Jun 3, 2026
Merged

diegosouzapw merged 3 commits into
release/v3.8.9from
chore/build-reorg-followups

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Re-applies two follow-up commits that landed on `refactor/build-output-isolation` after PR #3124 was merged (merge point was `0231fbb33`), so they were orphaned and never reached `release/v3.8.9`.

What's included

  • build(compat): `serve` CLI resolves `APP_DIR` with a `dist/server.js` probe and falls back to legacy `app/` — preserves upgrade safety for installs built before the output rename or partially replaced. Without this, the shipped `serve.mjs` hard-coded `dist/` and would not boot a legacy layout.
  • docs(deploy): deploy-vps skills now `pm2 stop → rsync --delete → pm2 start` to eliminate the transient `[Shutdown] Cannot find module ./chunks/NNNNN.js` race seen mid-deploy.
  • test(cli): TDD coverage for the `APP_DIR` `dist/ -> app/` fallback (replicated logic + source introspection).

Why a separate PR

#3124 was already merged when these were pushed; cherry-picking them onto a fresh branch keeps the release branch correct without touching the closed PR.

🤖 Generated with Claude Code

Backward-compat hardening: the npm CLI prefers the new dist/ standalone but falls
back to the legacy app/ location, so an upgrade over a partially-replaced install
(or a package built before the app/->dist/ rename) still boots. Deployed runtimes
(VPS app/, Docker /app, Electron resources/app) are unchanged by design.
… error

rsync --delete removing chunk files under a live server produced the transient [Shutdown] Cannot find module ./chunks/NNNNN.js. Stop the process first, then start with a clean module graph.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the deployment documentation across several skills to stop the PM2 process before running rsync, preventing transient chunk file errors during deployment. It also introduces a backward-compatibility fallback in bin/cli/commands/serve.mjs to resolve APP_DIR to the legacy app/ directory if dist/server.js is missing, along with corresponding unit tests. Feedback on the changes suggests refactoring a fragile test assertion in tests/unit/cli-serve-port.test.ts that strictly matches the source code formatting of the fallback logic, recommending a more robust and decoupled regular expression assertion instead.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +84 to +87
assert.match(
serveSource,
/existsSync\(join\(ROOT, "dist", "server\.js"\)\)\s*\?\s*join\(ROOT, "dist"\)\s*:\s*join\(ROOT, "app"\)/,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Fragile Test Assertion

Asserting on the exact source code formatting and syntax structure (such as the specific ternary operator layout, quote types, and spacing) via a strict regular expression is highly fragile. Any minor, non-functional change—such as running an auto-formatter (e.g., Prettier), changing single quotes to double quotes, or refactoring the ternary operator into an if/else block—will break this test even though the underlying behavior remains correct.

Recommendation

Make the assertions more robust and less sensitive to exact formatting by decoupling the checks. You can assert that dist/server.js is probed and that app is used as a fallback using separate, more flexible regular expressions.

  assert.match(serveSource, /existsSync\s*\(\s*join\s*\(\s*ROOT\s*,\s*['"]dist['"]\s*,\s*['"]server\.js['"]\s*\)\s*\)/);
  assert.match(serveSource, /join\s*\(\s*ROOT\s*,\s*['"]app['"]\s*\)/);

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96f3d22d50

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +64 to 65
ssh root@69.164.221.35 "pm2 stop omniroute" & ssh root@192.168.0.15 "pm2 stop omniroute" & wait
rsync -az --delete /home/diegosouzapw/dev/proxys/OmniRoute/dist/ root@69.164.221.35:/usr/lib/node_modules/omniroute/app/ && rsync -az --delete /home/diegosouzapw/dev/proxys/OmniRoute/dist/ root@192.168.0.15:/usr/lib/node_modules/omniroute/app/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate both rsyncs on successful PM2 stops

In the both-VPS workflow, if either ssh ... pm2 stop fails, this still proceeds to rsync --delete: Bash wait with no job operands returns success after waiting for all current jobs, so a failed stop is masked. In that failure scenario the host whose app is still live can have chunks deleted mid-request, recreating the [Shutdown] Cannot find module ./chunks/... race this step is meant to prevent; capture the PIDs and fail on each wait status, or otherwise chain the rsyncs only after both stops succeed.

Useful? React with 👍 / 👎.

Comment on lines +61 to 62
ssh root@69.164.221.35 "pm2 stop omniroute"
rsync -az --delete /home/diegosouzapw/dev/proxys/OmniRoute/dist/ root@69.164.221.35:/usr/lib/node_modules/omniroute/app/

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent rsync after a failed stop

For the single-host deploy flow, a transient SSH/PM2 failure on the stop command does not prevent the next line from running when this block is pasted or executed without set -e. That means rsync --delete can still update the bundle while the old process is live, which is exactly the chunk-deletion race described above; use ssh ... "pm2 stop omniroute" && rsync ... or an explicit failure check before syncing. The same pattern appears in the local VPS skill as well.

Useful? React with 👍 / 👎.

@kilo-code-bot

kilo-code-bot Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .agents/skills/deploy-vps-akamai-cc/SKILL.md
  • .agents/skills/deploy-vps-both-cc/SKILL.md
  • .agents/skills/deploy-vps-local-cc/SKILL.md
  • bin/cli/commands/serve.mjs
  • tests/unit/cli-serve-port.test.ts

Reviewed by nemotron-3-super-120b-a12b-20230311:free · 278,288 tokens

@diegosouzapw
diegosouzapw merged commit c9620eb into release/v3.8.9 Jun 3, 2026
2 checks passed
@diegosouzapw
diegosouzapw deleted the chore/build-reorg-followups branch June 3, 2026 21:12
@diegosouzapw diegosouzapw mentioned this pull request Jun 3, 2026
diegosouzapw added a commit that referenced this pull request Jun 3, 2026
…ors hall

Adds entries for #3097, #3101 (deepseek-web #2942/#2820), #3104, #3105, #3107,
#3109, #3111, #3113, #3115, #3122, #3125, #3127, #3129, plus a Contributors
section crediting all v3.8.9 contributors. Stamps the 3.8.9 release date.
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…oy docs) (cheaper-inference#3127)

* build(compat): serve CLI falls back dist/ -> app/ for upgrade safety

Backward-compat hardening: the npm CLI prefers the new dist/ standalone but falls
back to the legacy app/ location, so an upgrade over a partially-replaced install
(or a package built before the app/->dist/ rename) still boots. Deployed runtimes
(VPS app/, Docker /app, Electron resources/app) are unchanged by design.

* docs(deploy): stop pm2 before rsync --delete to avoid transient chunk error

rsync --delete removing chunk files under a live server produced the transient [Shutdown] Cannot find module ./chunks/NNNNN.js. Stop the process first, then start with a clean module graph.

* test(cli): cover serve APP_DIR dist/->app/ backward-compat fallback
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…oy docs) (cheaper-inference#3127)

* build(compat): serve CLI falls back dist/ -> app/ for upgrade safety

Backward-compat hardening: the npm CLI prefers the new dist/ standalone but falls
back to the legacy app/ location, so an upgrade over a partially-replaced install
(or a package built before the app/->dist/ rename) still boots. Deployed runtimes
(VPS app/, Docker /app, Electron resources/app) are unchanged by design.

* docs(deploy): stop pm2 before rsync --delete to avoid transient chunk error

rsync --delete removing chunk files under a live server produced the transient [Shutdown] Cannot find module ./chunks/NNNNN.js. Stop the process first, then start with a clean module graph.

* test(cli): cover serve APP_DIR dist/->app/ backward-compat fallback
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…oy docs) (cheaper-inference#3127)

* build(compat): serve CLI falls back dist/ -> app/ for upgrade safety

Backward-compat hardening: the npm CLI prefers the new dist/ standalone but falls
back to the legacy app/ location, so an upgrade over a partially-replaced install
(or a package built before the app/->dist/ rename) still boots. Deployed runtimes
(VPS app/, Docker /app, Electron resources/app) are unchanged by design.

* docs(deploy): stop pm2 before rsync --delete to avoid transient chunk error

rsync --delete removing chunk files under a live server produced the transient [Shutdown] Cannot find module ./chunks/NNNNN.js. Stop the process first, then start with a clean module graph.

* test(cli): cover serve APP_DIR dist/->app/ backward-compat fallback
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