From 311cd58a6e810e23ee2dd1acdeaf71e8cad08956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=27=C3=A9lectron=20rare?= <108685187+electron-rare@users.noreply.github.com> Date: Thu, 9 Jul 2026 12:40:16 +0200 Subject: [PATCH] fix: harden worklet caching and build guard Un-hashed libopenmpt.worklet.js was inheriting the immutable 1-year cache from /assets/, risking stale audio on chiptune3 bumps. Add a dedicated short-cache location for it. Also fail closeBundle loudly if the worklet source vanishes, instead of silently shipping a build with hanging audio. --- nginx.conf | 7 +++++++ vite.config.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index 3180ce4..4a2c22b 100644 --- a/nginx.conf +++ b/nginx.conf @@ -10,6 +10,13 @@ server { add_header X-Content-Type-Options nosniff; add_header Referrer-Policy no-referrer-when-downgrade; + # un-hashed file copied by chiptuneWorkletFix -- must not be immutable + location = /assets/libopenmpt.worklet.js { + add_header Cache-Control "public, max-age=86400"; + add_header X-Content-Type-Options nosniff; + add_header Referrer-Policy no-referrer-when-downgrade; + } + location /assets/ { # add_header is not inherited once a location declares its own add_header X-Content-Type-Options nosniff; diff --git a/vite.config.ts b/vite.config.ts index 7b1f9c0..224254d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -30,7 +30,11 @@ function chiptuneWorkletFix(): Plugin { }, closeBundle() { const src = resolve('node_modules/chiptune3/libopenmpt.worklet.js') - if (!existsSync(src)) return + if (!existsSync(src)) { + throw new Error( + 'chiptuneWorkletFix: libopenmpt.worklet.js not found — chiptune3 layout changed?', + ) + } const dest = resolve(outDir, assetsDir, 'libopenmpt.worklet.js') copyFileSync(src, dest) },