Skip to content

Overhaul SSR caching, dev hot-reload, and server memory footprint#200

Open
Uttkarsh-Srivastava wants to merge 16 commits intofeature/fetchPriorityLowfrom
feature/fix-memory-usage-v3
Open

Overhaul SSR caching, dev hot-reload, and server memory footprint#200
Uttkarsh-Srivastava wants to merge 16 commits intofeature/fetchPriorityLowfrom
feature/fix-memory-usage-v3

Conversation

@Uttkarsh-Srivastava
Copy link
Collaborator

Summary

  • ChunkExtractor caching (production)ChunkExtractor instances are now cached per route instead of being created on every request. loadable-stats.json is also parsed once and held in memory, eliminating repeated disk reads.
  • Simplified asset extractionextract.js refactored to derive CSS and preload JS links directly from the cached ChunkExtractor instance, removing the separate routeCssCache and preloadJSLinkCache maps.
  • SSR compiler removed from dev client process — The SSR webpack watcher that ran in the same process as the client dev server has been removed. SSR now runs in a separate process, reducing peak memory usage during development.
  • Webpack filesystem cache (dev) — Enabled webpack filesystem cache in development mode (written to node_modules/catalyst-core/.cache/webpack), reducing rebuild memory pressure and speeding up incremental builds.
  • Hot-reload overhaul — Replaced --watch-path flags with a chokidar watcher inside startServer.js that watches the app's /server directory. On change, require cache is cleared (clearServerCache) and the server restarts cleanly.
  • Fixed EADDRINUSE race conditionrestartServer() now nulls serverInstance before calling close(), preventing concurrent watcher events from each scheduling an independent startServer() callback on the same closing socket.
  • Port availability pre-check — Both the Node server and the webpack dev server now probe their target port with a temporary TCP server before binding, surfacing a clear error instead of a cryptic EADDRINUSE.
  • Unified handler for dev and prod — Removed the separate handler.development.js SSR bundle. Both environments now use the same handler.js entrypoint.
  • cleanCache CLI command — New catalyst cleanCache command removes the webpack filesystem cache and loadable-stats.json, forcing a full rebuild on next dev start.
  • Body parser size limits — JSON and raw body parsers capped at 100kb to prevent oversized payloads from inflating heap usage.
  • eval-cheap-module-source-map devtool — Switched from inline-source-map (embeds full source maps in bundles) to eval-cheap-module-source-map for faster builds and lower memory footprint in dev.
  • React Refresh babel plugin — Added react-refresh/babel to the development Babel env for proper fast-refresh support.
  • Removed css-hot-loader — Dropped the old CSS hot loader; CSS updates are now handled through React Refresh and the webpack dev server HMR pipeline.

utkarsh-1mg and others added 14 commits January 13, 2026 16:32
…ross platforms

Replaced Node.js native --watch-path flags on Windows with chokidar-based
watching (already used on Mac/Linux), eliminating the double-trigger bug
where a single /server file change caused both a process-level restart and
an in-process Express restart simultaneously.

Also fixes EADDRINUSE race condition by introducing restartServer() which
nulls serverInstance before close(), preventing concurrent chokidar events
from each queuing independent startServer() callbacks on the same socket.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@deputydev-agent
Copy link

DeputyDev will no longer review pull requests automatically.To request a review, simply comment #review on your pull request—this will trigger an on-demand review whenever you need it.

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