From fa5cd002f43dd1048446224dfef6b7cc3a6870c8 Mon Sep 17 00:00:00 2001 From: pfg Date: Fri, 26 Sep 2025 18:31:13 -0700 Subject: [PATCH] unflake stress --- src/bake/hmr-runtime-client.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/bake/hmr-runtime-client.ts b/src/bake/hmr-runtime-client.ts index bebe2dcc34..7444cf5130 100644 --- a/src/bake/hmr-runtime-client.ts +++ b/src/bake/hmr-runtime-client.ts @@ -71,16 +71,35 @@ globalThis[Symbol.for("bun:hmr")] = (modules: any, id: string) => { if (!entry) throw new Error("Unknown HMR script: " + id); const [script, size] = entry; scriptTags.delete(id); + + // Filter out HTML files - they should trigger a full page reload instead + const filteredModules: any = {}; + let hasHtmlFile = false; + for (const key in modules) { + if (key.endsWith(".html")) { + hasHtmlFile = true; + } else { + filteredModules[key] = modules[key]; + } + } + + // If there were HTML files, trigger a full page reload + if (hasHtmlFile) { + script.remove(); + fullReload(); + return; + } + const url = script.src; const map: SourceMapURL = { id, url, - refs: Object.keys(modules).length, + refs: Object.keys(filteredModules).length, size, }; addMapping(url, map); script.remove(); - replaceModules(modules, map).catch(e => { + replaceModules(filteredModules, map).catch(e => { console.error(e); fullReload(); });