From e4502f243795aff279b942596c38a566e83c5456 Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Sun, 9 Aug 2026 12:56:11 +0530 Subject: [PATCH] fix(dev-server): isolate generated cache per process --- packages/dev-server/src/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/dev-server/src/index.ts b/packages/dev-server/src/index.ts index 2113e7fc..5a98f0fd 100644 --- a/packages/dev-server/src/index.ts +++ b/packages/dev-server/src/index.ts @@ -272,7 +272,11 @@ export async function startServer(opts: ServeOptions): Promise { const pluginContributions = await pluginRunner.contributions(); const virtualModules = new Map(); - const virtualDir = join(appRoot, ".wrnexus", "virtual"); + // A live dev server and a test process can share an app root. Keeping the + // generated artifacts in a process-specific directory prevents a test boot + // from deleting the running server's client modules. + const cacheDir = join(appRoot, `.wrnexus-${process.pid}`); + const virtualDir = join(cacheDir, "virtual"); mkdirSync(virtualDir, { recursive: true }); for (const [index, module] of pluginContributions.virtualModules.entries()) { const output = join(virtualDir, `plugin-${index}.ts`); @@ -327,12 +331,13 @@ export async function startServer(opts: ServeOptions): Promise { resetDevCache({ rootDir: appRoot, + cacheDir, enabled: process.env.WRNEXUS_PRESERVE_CACHE !== "1", }); // Compile every `.wrn` into ONE cache dir at the project root, instead of a // `.wrnexus/` next to each source file (and inside node_modules UI dirs). - setCompileCacheDir(join(appRoot, ".wrnexus")); + setCompileCacheDir(cacheDir); const theme = resolveThemeConfig(opts.theme); const uiStylesPath = uiCssPath();