diff --git a/server/src/__tests__/http-log-policy.test.ts b/server/src/__tests__/http-log-policy.test.ts index ec140c3e878..0e540a11161 100644 --- a/server/src/__tests__/http-log-policy.test.ts +++ b/server/src/__tests__/http-log-policy.test.ts @@ -53,6 +53,8 @@ describe("shouldSilenceHttpSuccessLog", () => { }); it("silences successful static asset requests", () => { + expect(shouldSilenceHttpSuccessLog("GET", "/", 200)).toBe(true); + expect(shouldSilenceHttpSuccessLog("GET", "/index.html", 200)).toBe(true); expect(shouldSilenceHttpSuccessLog("GET", "/@fs/Users/dotta/paperclip/ui/src/main.tsx", 200)).toBe(true); expect(shouldSilenceHttpSuccessLog("GET", "/src/App.tsx?t=123", 200)).toBe(true); expect(shouldSilenceHttpSuccessLog("GET", "/site.webmanifest", 200)).toBe(true); diff --git a/server/src/__tests__/vite-html-renderer.test.ts b/server/src/__tests__/vite-html-renderer.test.ts index f958ce79b8b..add3ba80045 100644 --- a/server/src/__tests__/vite-html-renderer.test.ts +++ b/server/src/__tests__/vite-html-renderer.test.ts @@ -32,7 +32,7 @@ describe("createCachedViteHtmlRenderer", () => { } }); - it("reuses the injected dev html shell until a watched file changes", async () => { + it("reuses the injected dev html shell until index.html changes", async () => { const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-vite-html-")); tempDirs.push(tempDir); const indexPath = path.join(tempDir, "index.html"); @@ -57,6 +57,12 @@ describe("createCachedViteHtmlRenderer", () => { expect(first.match(/\/@vite\/client/g)?.length).toBe(1); expect(first).toContain("window.$RefreshReg$"); + const sourcePath = path.join(tempDir, "src", "main.tsx"); + fs.mkdirSync(path.dirname(sourcePath), { recursive: true }); + fs.writeFileSync(sourcePath, "export {};\n", "utf8"); + watcher.emit("change", sourcePath); + expect(await renderer.render("/")).toBe(first); + fs.writeFileSync( indexPath, '
v2', diff --git a/server/src/middleware/http-log-policy.ts b/server/src/middleware/http-log-policy.ts index d652ee38d09..a0b93694b22 100644 --- a/server/src/middleware/http-log-policy.ts +++ b/server/src/middleware/http-log-policy.ts @@ -23,6 +23,8 @@ const SILENCED_SUCCESS_STATIC_PREFIXES = [ ]; const SILENCED_SUCCESS_STATIC_PATHS = new Set([ + "/", + "/index.html", "/favicon.ico", "/site.webmanifest", "/sw.js", diff --git a/server/src/vite-html-renderer.ts b/server/src/vite-html-renderer.ts index 4834591acf6..983a3ea1586 100644 --- a/server/src/vite-html-renderer.ts +++ b/server/src/vite-html-renderer.ts @@ -63,7 +63,7 @@ export function createCachedViteHtmlRenderer(opts: { function onWatchEvent(filePath: string): void { const resolvedPath = path.resolve(filePath); - if (resolvedPath === templatePath || resolvedPath.startsWith(`${uiRoot}${path.sep}`)) { + if (resolvedPath === templatePath) { invalidate(); } }