Two concurrent `docusaurus start` processes share one Rspack persistent cache: next start panics (3.10) or a server aborts (4.0 canary)
Have you read the Contributing Guidelines on issues?
- I have read the Contributing Guidelines on issues.
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clearoryarn clearcommand. - I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - I have tried creating a repro with https://new.docusaurus.io. (The repro needs two local dev servers and a shared
node_modules/.cache, so it is a freshcreate-docusaurusproject instead.) - I have read the console error message carefully (if applicable).
Description
When two docusaurus start processes run on the same site at the same time (for example on two ports, or an editor-launched server plus a terminal one), both use the same Rspack persistent cache directory with the same cache version (<name>-development-<locale>-..., from getCacheName() in webpack/base.ts). Nothing prevents them from writing it concurrently.
If files change while both are running, so both recompile and persist, things break. On 3.10.2 the cache ends up inconsistent and the next docusaurus start aborts the whole Node process with a Rust panic:
Panic occurred at runtime. Please file an issue on GitHub with the backtrace below: https://github.com/web-infra-dev/rspack/issues: panicked at crates/rspack_core/src/module_graph/mod.rs:722:26:
ModuleGraphModule with identifier Identifier(u!("<site>/node_modules/react/jsx-runtime.js")) not found
Abort trap: 6On 4.0.0-canary-6848 (Rspack 2.2.7) the restart no longer panics, because Rspack now guards the cache with a transaction directory. The second process runs into that guard instead: in 1 of 5 rounds it aborted mid-session,
thread 'tokio-9' panicked at <redacted>:0:0:
Transaction already in progress by process 52292:node in directory '<site>/node_modules/.cache/rspack/client-development/rspack_v_ef3dc523a56e4030/.temp'
Abort trap: 6and in the other 4 rounds both servers logged a failed cache save:
Rspack persistent cache save failed: Rspack FS Error: IO error: failed to remove directory `<site>/node_modules/.cache/rspack/client-development/rspack_v_ef3dc523a56e4030/.temp`: Directory not empty (os error 66)On 3.10.2 docusaurus clear fixes it, until it happens again. While a dev server is running, docusaurus clear itself fails with ENOTEMPTY on the cache folder.
This looks like the real-world path behind several Rspack reports that were closed for lack of a reproduction, all coming from Docusaurus users: web-infra-dev/rspack#15157, web-infra-dev/rspack#14064. The panic itself (recovering an incomplete module graph aborts instead of rebuilding) is tracked in web-infra-dev/rspack#14860. The Docusaurus side is that two dev servers share one persistent cache with no coordination.
docusaurus build uses a different cache version (production), so a build does not share these cache files with a dev server. I only looked at two dev servers.
Reproducible demo
https://github.com/wonkooklee/docusaurus-rspack-cache-repro (fresh classic template, 3.10.2 + @docusaurus/faster, plus repro.sh)
Steps to reproduce
npx [email protected] mini classic --javascript, add@docusaurus/[email protected], setfuture: { v4: true, faster: true }.npx docusaurus clear- Start two dev servers:
npx docusaurus start --port 3100andnpx docusaurus start --port 3101. - Wait for both to compile, then edit
docs/intro.mdxandsrc/css/custom.cssthree times, about 12 seconds apart, so both servers recompile. - Stop both servers (Ctrl+C).
npx docusaurus start --port 3100
The steps as a script (repro.sh, macOS, bash):
#!/usr/bin/env bash
set -u
cd "$(dirname "$0")"
stop() { pkill -INT -f "docusaurus start --port $1" 2>/dev/null; for i in $(seq 1 30); do lsof -ti tcp:$1 >/dev/null 2>&1 || return 0; sleep 1; done; lsof -ti tcp:$1 | xargs kill -9 2>/dev/null; }
ready() { for i in $(seq 1 180); do grep -qiE 'compiled successfully|compiled with|panicked' "$1" 2>/dev/null && return 0; sleep 1; done; }
stop 3100; stop 3101
npx docusaurus clear >/dev/null
npx docusaurus start --port 3100 --no-open > a.log 2>&1 &
npx docusaurus start --port 3101 --no-open > b.log 2>&1 &
ready a.log; ready b.log; sleep 5
cp intro.mdx.orig docs/intro.mdx
for i in 1 2 3; do printf "\nEdit %s.\n" "$i" >> docs/intro.mdx; touch src/css/custom.css; sleep 12; done
cp intro.mdx.orig docs/intro.mdx
stop 3100; stop 3101
npx docusaurus start --port 3100 --no-open > c.log 2>&1 &
ready c.log; sleep 1; stop 3100
if grep -qi panicked c.log; then echo "REPRODUCED"; grep -i -A1 -m1 panicked c.log; exit 1; else echo "not reproduced"; fi(intro.mdx.orig is a copy of the original docs/intro.mdx.)
Results, each round from a cleared cache:
| Setup | Panic on restart |
|---|---|
| 3.10.2, two dev servers, edits while both run | 5/5 |
| 3.10.2, one dev server, same edits | 0/4 (tested on a larger site) |
3.10.2, second server with DOCUSAURUS_NO_PERSISTENT_CACHE=1 |
0/4 (larger site) |
| 3.10.2, one server killed with SIGKILL right after compiling | 0/6 (larger site) |
| 4.0.0-canary-6848 (Rspack 2.2.7, Node 24.21), two dev servers | 0/5 on restart, but in 1/5 a running server aborted, and in the other 4/5 both servers logged a failed cache save |
Expected behavior
A second docusaurus start on the same site should not be able to corrupt the persistent cache of the first. Either it uses its own cache, or it runs without the persistent cache and says so.
Actual behavior
Both processes use the same persistent cache concurrently. On 3.10.2 the next docusaurus start aborts with the Rust panic above. On 4.0 canary a running server can abort, and otherwise cache saves fail with the error above.
Your environment
- Docusaurus: 3.10.2 (
@docusaurus/faster3.10.2,@rspack/core1.7.12). Also 4.0.0-canary-6848 (@rspack/core2.2.7). - Node.js: 22.12.0 (3.10.2), 24.21.0 (canary)
- OS: macOS (Darwin 25.6.0, arm64)
- Package manager: npm (minimal repro); first seen with Yarn 4 on a real site
Self-service
- I'd be willing to fix this bug myself.
Proposed fix: in start, take a lock file (for example node_modules/.cache/.docusaurus-start.lock holding the PID, created with wx, removed on exit, a stale lock taken over when its PID is dead). If another live start holds it, log a warning and disable the persistent cache for this process, which is the existing DOCUSAURUS_NO_PERSISTENT_CACHE path. I patched this into 3.10.2's lib/commands/start/start.js; with it, the same repro gave 0/5 panics (was 5/5), and one of the two servers printed the warning each round. I have not tried it on canary yet. Happy to open a PR against main if this direction is acceptable.
Source: facebook/docusaurus