Skip to content

[Bug]: Dev server's in-memory output file system keeps every hot-update file #8736

Closed

Description

@Sheraff

Investigated and written with the help of an AI coding agent (Claude); reproduced locally.

Version

System:
  OS: Linux 6.12 Debian GNU/Linux 13 (trixie)
  CPU: (32) x64 AMD Ryzen 9 9955HX 16-Core Processor
  Node: 26.10.0, npm 12.2.0
npmPackages:
  @rsbuild/core: 2.2.14 (@rspack/core 2.2.9, memfs 4.80.0)

Details

In dev (writeToDisk: false), the memfs output file system never drops old files. Every edit adds index.<hash>.hot-update.{js,js.map,json}, and a chunk that a rebuild no longer emits (removed or renamed dynamic import) stays too. Memory grows with every save for the life of the dev server. No browser needs to be connected.

The repro rewrites src/index.js N times and lists compiler.outputFileSystem after each batch:

$ node repro.mjs --cycles=100
edits=   0 memfsFiles=   5 hotUpdateFiles=   0 memfsBytes=  0.1MB
edits=  50 memfsFiles= 155 hotUpdateFiles= 150 memfsBytes=  1.2MB
edits= 100 memfsFiles= 311 hotUpdateFiles= 306 memfsBytes=  2.3MB

$ node repro.mjs --cycles=50 --rotate-chunk   # each edit also swaps chunks/lazy-<i>.js for a new one
edits=  50 memfsFiles= 278 hotUpdateFiles= 171 lazyChunkFiles= 102 memfsBytes=  1.7MB

The bytes scale with the edited modules; in a mid-sized app we saw ~260 KB retained per save.

With tools: { rspack: { output: { clean: true } } } the volume stays flat and HMR still works:

$ node repro.mjs --cycles=50 --rspack-clean
edits=   0 memfsFiles=   5 hotUpdateFiles=   0 memfsBytes=  0.1MB
edits=  50 memfsFiles=   8 hotUpdateFiles=   3 memfsBytes=  0.2MB

Expected: a roughly constant number of files in the dev output file system across edits, without the output.clean override. For example, prune it after each compilation (or enable output.clean for the memfs case), keeping the last hot update or two for clients one step behind.

Related: #8507 (memfs buffer over-allocation, different), rspack#9391.

Reproduce link

https://github.com/Sheraff/rsbuild-dev-memfs-hot-updates

Reproduce Steps

  1. npm install
  2. npm run repro: prints the memfs file count growing by 3 per edit
  3. Control: node repro.mjs --cycles=50 --rspack-clean stays at 8 files

Activity

  1. self-assigned this
    on Oct 27, 2026
  2. chenjiahan commented on Oct 27, 2026

    @chenjiahan
    Member

    Thanks for the feedback! This issue will be fixed in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions