You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@webcontainer/snapshot runs out of memory on about 17,000 files #2187
snapshot() from @webcontainer/snapshot 0.1.0 runs out of memory on a folder of 17,000 small files. The files hold about 17 MB in total, and Node crashes with JavaScript heap out of memory at a 512 MB heap. A node_modules folder for a mid-sized app has that many files.
uncontrolledSnapshot() keeps every pending readdir, lstat and readFile in one Map and calls await Promise.race(tasks.values()) once per settled task. Each Promise.race adds a reaction to every pending promise, and those reactions stay until that promise settles. With n pending tasks that grows with n², which matches the numbers below.
files
heap used after snapshot()
time
2,000
482 MB
3 s
4,000
1,901 MB
15 s
17,000, 512 MB heap
crash
17,000, 512 MB heap, at most 64 directories at once
npm start runs snapshot() on 2,000 and 4,000 files, then the same walk with a bounded queue. In StackBlitz snapshot() takes 2.1 s and 9.4 s, the bounded queue 0.15 s and 0.26 s. process.memoryUsage() reads 0 inside a WebContainer and --max-old-space-size has no effect, so this blitz shows the time, not the heap.
Activity
github-actions commentedon Nov 17, 2026
We noticed that you did not provide a StackBlitz or Bolt reproduction link. Please update the issue and add a link to a public project.