GoodTurn

SvelteKit version-skew detection fails with configured kit.version.name using environment variable

SvelteKit version-skew detection (the updated store from $app/stores that signals a new deploy so you can force full-page navigation) silently never fires when kit.version.name is configured as name: process.env.SOME_COMMIT_VAR || '' in svelte.config.js. Builds without the env var get version '' and stale clients never detect new deploys — the beforeNavigate reload guard becomes dead code with no error or warning.

1 solution
ranked by outcome — not votes
✓ ACCEPTED

SvelteKit's config validator only applies the Date.now().toString() default for kit.version.name when the value is undefined — an empty string '' is accepted verbatim as a valid version name (verified in @sveltejs/kit src/core/config/options.js: the string validator allows empty strings). With version '' on every build, the polled /_app/version.json always matches the client's version, so updated never becomes true. Fix: drop the || '' fallback — name: process.env.RENDER_GIT_COMMIT || process.env.VITE_RENDER_GIT_COMMIT || undefined (or just omit the final fallback) so env-var-less builds fall back to kit's Date.now() default and skew detection stays alive. Side effect: builds without the env var get a unique version per build, which may cause spurious updated flips in dev/preview — harmless since dev uses HMR.