From bdb36d6be4dd9c344a7d6a8dcb7124b427db5fd2 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jun 2025 02:59:31 -0400 Subject: [PATCH 1/3] disable caching for frontend assets This aims to fix the issue where it says ``` TypeError Cannot read properties of undefined (reading 'component') ``` by telling the browser to not cache any chunks --- backend/src/server/plugins/serve-ui.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/server/plugins/serve-ui.ts b/backend/src/server/plugins/serve-ui.ts index 22c097726..fc6b85d3d 100644 --- a/backend/src/server/plugins/serve-ui.ts +++ b/backend/src/server/plugins/serve-ui.ts @@ -57,9 +57,12 @@ export const registerServeUI = async ( reply.callNotFound(); return; } - // reference: https://github.com/fastify/fastify-static?tab=readme-ov-file#managing-cache-control-headers - // to avoid ui bundle skew on new deployment - return reply.sendFile("index.html", { maxAge: 0, immutable: false }); + + // This should help avoid caching any chunks (temp) + reply.header('Cache-Control', 'no-cache, no-store, must-revalidate'); + reply.header('Pragma', 'no-cache'); + return reply.sendFile("index.html"); + } }); } From 2d3c63e8b933efca9d1dff82b4998e5e1bf01ed7 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jun 2025 03:10:16 -0400 Subject: [PATCH 2/3] fix lint --- backend/src/server/plugins/serve-ui.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/backend/src/server/plugins/serve-ui.ts b/backend/src/server/plugins/serve-ui.ts index fc6b85d3d..9904c992f 100644 --- a/backend/src/server/plugins/serve-ui.ts +++ b/backend/src/server/plugins/serve-ui.ts @@ -57,12 +57,11 @@ export const registerServeUI = async ( reply.callNotFound(); return; } - + // This should help avoid caching any chunks (temp) - reply.header('Cache-Control', 'no-cache, no-store, must-revalidate'); - reply.header('Pragma', 'no-cache'); + reply.header("Cache-Control", "no-cache, no-store, must-revalidate"); + reply.header("Pragma", "no-cache"); return reply.sendFile("index.html"); - } }); } From 26bed22b949029778fc5ed8ea1c6a7ba3be4e4dd Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jun 2025 17:05:10 -0400 Subject: [PATCH 3/3] fix lint by adding void --- backend/src/server/plugins/serve-ui.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/server/plugins/serve-ui.ts b/backend/src/server/plugins/serve-ui.ts index 9904c992f..b71451b6e 100644 --- a/backend/src/server/plugins/serve-ui.ts +++ b/backend/src/server/plugins/serve-ui.ts @@ -58,9 +58,10 @@ export const registerServeUI = async ( return; } - // This should help avoid caching any chunks (temp) - reply.header("Cache-Control", "no-cache, no-store, must-revalidate"); - reply.header("Pragma", "no-cache"); + // This should help avoid caching any chunks (temp fix) + void reply.header("Cache-Control", "no-cache, no-store, must-revalidate, private, max-age=0"); + void reply.header("Pragma", "no-cache"); + void reply.header("Expires", "0"); return reply.sendFile("index.html"); } });