Skip to content

feat: add liveReload option to disable dev WS#23

Merged
khromov merged 3 commits into
mainfrom
fix-reload-in-prod
May 23, 2026
Merged

feat: add liveReload option to disable dev WS#23
khromov merged 3 commits into
mainfrom
fix-reload-in-prod

Conversation

@khromov

@khromov khromov commented May 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • New top-level liveReload?: boolean option on MochiServeOptions. Defaults to development. Set to false to keep the debug bar but skip the /__mochi_live_reload WS and the mochi-live-reload web component.
  • Motivation: the dev WS is flaky behind the proxy fronting the demo Docker images — dropped connections trigger location.reload() on reconnect, surfacing as unexplained reloads for visitors.
  • Wired MOCHI_LIVE_RELOAD=false into the dev-mode Dockerfile (which runs both site and demos) so deployed demos keep the bar but drop the WS. Normal bun run dev is unchanged.

Test plan

  • bun run checks (lint + typecheck + tests, all workspaces) passes
  • Smoke test: MODE=development PORT=4444 bun packages/site/src/index.ts → response has mochi-live-reload, mochi-dev-toolbar, and __mochi_page_entry as before
  • Smoke test: same with MOCHI_LIVE_RELOAD=falsemochi-dev-toolbar still present, mochi-live-reload and __mochi_page_entry gone, and a WS upgrade against /__mochi_live_reload is rejected with 400

Adds a top-level `liveReload?: boolean` to `MochiServeOptions` that
defaults to `development`. Set to `false` to keep the debug bar but
skip the `/__mochi_live_reload` WS — the socket is flaky behind the
proxy fronting the demo Docker images and dropped connections trigger
a `location.reload()` on reconnect.

Site + demos entrypoints now read `MOCHI_LIVE_RELOAD=false`, set by
the dev-mode Dockerfile so the deployed demos keep the bar but ditch
the WS.
@github-actions

github-actions Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Mochi review report

Lines of code (non-blank lines)

packages/mochi

Category main PR Δ
src/Mochi.ts 1088 1089 +1
src/{types.ts,*.d.ts} 593 601 +8
Docs 3424 3435 +11
Total 18966 18986 +20

Unchanged: src/**/*.test.ts (5440), src/ComponentRegistry.ts (1367), src/hooks.ts (229), src/{requestContext,forms,errors}.ts (247), src/{events,log,logger}.ts (317), src/consoleLogger.ts (342), src/cookies*.ts (157), src/extensions.ts (191), src/cache.ts (60), src/middleware/** (81), src/enhance*.ts (184), src/build*.ts (251), src/proxy.ts (125), src/cli* (110), src/{csrf,serverIslandCrypto}.ts (240), src/web-components/** (431), src/debug-bar/** (1372), src/templates/** (790), Other (1927).

packages/site

Category main PR Δ
Other 1346 1347 +1
Total 9636 9637 +1

Unchanged: src/demos/** (5488), src/components/** (2079), src/lib/** (697), src/stores/** (26).

packages/demos

Category main PR Δ
Other 2003 2004 +1
Total 3088 3089 +1

Unchanged: src/hn/** (1085).

packages/minimal

Category main PR Δ
Total 537 537 0

Unchanged: Other (537).

packages/cli

Category main PR Δ
Total 502 502 0

Unchanged: src/**/*.test.ts (117), src/cli* (161), src/{create,templates,utils}.ts (220), Other (4).

@khromov khromov merged commit 616ab7a into main May 23, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request May 23, 2026
khromov added a commit that referenced this pull request May 23, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>mochi-framework: 0.3.0</summary>

##
[0.3.0](mochi-framework-v0.2.0...mochi-framework-v0.3.0)
(2026-05-23)


### Features

* add liveReload option to disable dev WS
([#23](#23))
([616ab7a](616ab7a))
* **mdsvex:** preprocess mochi:hydrate inside markdown files
([#22](#22))
([bcf08e4](bcf08e4))


### Bug Fixes

* **debug-bar:** show green status dot when liveReload is disabled
([#27](#27))
([f8896f5](f8896f5))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Stanislav Khromov <stanislav.khromov+github@gmail.com>
@khromov khromov deleted the fix-reload-in-prod branch June 6, 2026 20:37
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