Skip to content

fix: auto-start WS server in-process and change default port to 20132 - #6072

Merged
diegosouzapw merged 7 commits into
diegosouzapw:release/v3.8.47from
ianriizky:feat/ws-server-auto-start-inprocess-20132
Jul 11, 2026
Merged

diegosouzapw merged 7 commits into
diegosouzapw:release/v3.8.47from
ianriizky:feat/ws-server-auto-start-inprocess-20132

Conversation

@ianriizky

@ianriizky ianriizky commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The WS server now auto-starts in-process via instrumentation-node.ts using await import("@/server/ws/liveServer") inside the isBackgroundServicesDisabled() guard. No longer requires a separate sidecar script across all deployment modes (dev, production, Docker, Electron).
  • Default WS server port changed from 20129 to 20132 to avoid port conflict with API_PORT (20129) in split-port mode configurations.
  • Removed deprecated OMNIROUTE_DISABLE_LIVE_WS environment variable. Consolidated to OMNIROUTE_ENABLE_LIVE_WS (default: enabled) across all code, scripts, and documentation.
  • Added LIVE_WS_PORT to docker-compose.yml (env only, no port mapping).
  • Live WebSocket path is now derived from the pathname of NEXT_PUBLIC_LIVE_WS_PUBLIC_URL instead of being hardcoded to /live-ws. The path is extracted from the URL (e.g. wss://ws.my-ai.com/my-ws → /my-ws), with /live-ws as fallback. Shared via src/shared/utils/wsPath.ts and used by the handshake response, client hook, and dev proxy.

Related Issues

  • Closes #
  • Related to #

Validation

  • npm run typecheck:core
  • npm run test:unit (24 existing tests + 1 new regression test — all passed)
  • node --import tsx/esm --test tests/unit/live-ws-public-url.test.ts (7 tests — 5 existing + 2 new path derivation tests — all passed)
  • npm run test:coverage
  • Coverage is still >= 60% for statements, lines, functions, and branches
  • SonarQube PR analysis is green or any remaining issues are explicitly documented below

Tests Added Or Updated

Coverage Notes

Reviewer Notes

  • Port change: Operators who explicitly set LIVE_WS_PORT=20129 in their .env are unaffected (env var overrides the default). Operators relying on the default need to update firewall/proxy rules from 20129 to 20132.
  • Env var removal: OMNIROUTE_DISABLE_LIVE_WS was removed from .env.example, .env, docs/reference/ENVIRONMENT.md, and scripts/start-ws-server.mjs. Operators using OMNIROUTE_DISABLE_LIVE_WS=1 should migrate to OMNIROUTE_ENABLE_LIVE_WS=0.
  • Docker: LIVE_WS_PORT added to the x-common anchor and the omniroute-host profile environment. No port mapping added — the WS server binds to loopback inside the container.
  • Auto-start guard: The import is wrapped in try/catch (non-fatal) inside the isBackgroundServicesDisabled() block, so a WS server failure won't crash the application startup.
  • WS path derivation: The path is parsed from NEXT_PUBLIC_LIVE_WS_PUBLIC_URL at runtime (server-side) and at build time (client-side). Only ws:///wss:// URLs are accepted for path extraction; non-ws URLs fall back to /live-ws. In Docker prebuilt scenarios where the env var is set at runtime but wasn't available at build time, the client discovers the path via the handshake response body.live.path.
  • Dev proxy fix: The startsWith("/live-ws") check in standalone-server-ws.mjs was changed to startsWith(LIVE_WS_PATH + "/") to avoid false positives (e.g. /live-ws-custom matching /live-ws).

ghost 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 default live WebSocket port from 20129 to 20132 across the codebase, switches the configuration from a disable flag to an enable flag (OMNIROUTE_ENABLE_LIVE_WS), and introduces a utility to dynamically derive the WebSocket path from the public URL. Feedback on the changes suggests using the standard URL API instead of String.prototype.replace() in src/hooks/useLiveDashboard.ts to safely update the WebSocket URL's pathname and prevent potential string replacement bugs.

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 thread src/hooks/useLiveDashboard.ts Outdated
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.44 to release/v3.8.45 July 4, 2026 17:36
@ianriizky
ianriizky force-pushed the feat/ws-server-auto-start-inprocess-20132 branch from 6c5b845 to 8ff61c3 Compare July 5, 2026 00:34
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.45 to release/v3.8.46 July 6, 2026 04:09
@diegosouzapw

ghost commented Jul 6, 2026

Copy link
Copy Markdown
Owner

🔀 Cycle moved: base retargeted to release/v3.8.46 — release/v3.8.45 is frozen for the release in progress (#6313). No action needed.

@ianriizky
ianriizky marked this pull request as ready for review July 6, 2026 05:44
@ianriizky
ianriizky requested a review from diegosouzapw as a code owner July 6, 2026 05:44
@gemini-code-assist

ghost commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Septianata Rizky Pratama added 5 commits July 6, 2026 14:23
Update the default WebSocket port for the live dashboard server from 20129 to 20132 across all configuration files, documentation, code comments, and tests. Also consolidate OMNIROUTE_DISABLE_LIVE_WS and OMNIROUTE_ENABLE_LIVE_WS into a single OMNIROUTE_ENABLE_LIVE_WS flag. Wire the live WebSocket server to start in-process via instrumentation-node.ts.
…grade path from URL

Update .env.example and ENVIRONMENT.md to document that the pathname portion of NEXT_PUBLIC_LIVE_WS_PUBLIC_URL (e.g. /live-ws) is used as the WebSocket upgrade path by the dev proxy, handshake response, and client connection logic.

Extract deriveLiveWsPath() into shared/utils/wsPath.ts and wire it through:
- src/app/api/v1/ws/route.ts — handshake response path field
- src/hooks/useLiveDashboard.ts — build
…rigins

Add LIVE_WS_PORT (20132), LIVE_WS_HOST (0.0.0.0), and LIVE_WS_ALLOWED_ORIGINS environment variables to all Docker Compose profiles and expose the WebSocket port mapping. Prevent infinite self-loop in standalone-server-ws.mjs by skipping proxy when the server itself is running on the LiveWS port.
@ianriizky
ianriizky force-pushed the feat/ws-server-auto-start-inprocess-20132 branch from 919e49c to f7aa89e Compare July 6, 2026 07:33
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.46 to release/v3.8.47 July 7, 2026 11:04
Septianata Rizky Pratama and others added 2 commits July 10, 2026 20:23
The fork predates diegosouzapw#6324 (EADDRINUSE crash-loop guard). Merging restores
the wss.once("error", reject) handler in startLiveDashboardServer()
alongside this PR's auto-start-in-process changes — both are
complementary and needed together.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
@diegosouzapw
diegosouzapw merged commit 45310f2 into diegosouzapw:release/v3.8.47 Jul 11, 2026
@diegosouzapw

ghost commented Jul 11, 2026

Copy link
Copy Markdown
Owner

@ianriizky thanks for the in-process WS auto-start (+ default port 20132) — merged into release/v3.8.47. 🙏

@ianriizky

ghost commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@ianriizky thanks for the in-process WS auto-start (+ default port 20132) — merged into release/v3.8.47. 🙏

I really appreciate man. I'll look up for another issue you need to solve 🤝.

@diegosouzapw diegosouzapw mentioned this pull request Jul 11, 2026
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.

2 participants