diff --git a/.changeset/serious-bulldogs-beam.md b/.changeset/serious-bulldogs-beam.md new file mode 100644 index 000000000000..e41920379db8 --- /dev/null +++ b/.changeset/serious-bulldogs-beam.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: avoid creating update check timer on the server diff --git a/packages/kit/src/runtime/client/singletons.js b/packages/kit/src/runtime/client/singletons.js index 6316373753dd..f92efb259a3b 100644 --- a/packages/kit/src/runtime/client/singletons.js +++ b/packages/kit/src/runtime/client/singletons.js @@ -44,8 +44,8 @@ export function client_method(key) { } export const stores = { - url: notifiable_store({}), - page: notifiable_store({}), - navigating: writable(/** @type {import('types').Navigation | null} */ (null)), - updated: create_updated_store() + url: /* @__PURE__ */ notifiable_store({}), + page: /* @__PURE__ */ notifiable_store({}), + navigating: /* @__PURE__ */ writable(/** @type {import('types').Navigation | null} */ (null)), + updated: /* @__PURE__ */ create_updated_store() }; diff --git a/packages/kit/src/runtime/client/utils.js b/packages/kit/src/runtime/client/utils.js index 7818d6ac91ed..1ac2aeff9a6c 100644 --- a/packages/kit/src/runtime/client/utils.js +++ b/packages/kit/src/runtime/client/utils.js @@ -219,6 +219,13 @@ export function notifiable_store(value) { export function create_updated_store() { const { set, subscribe } = writable(false); + if (DEV || !BROWSER) { + return { + subscribe, + check: async () => false + }; + } + const interval = __SVELTEKIT_APP_VERSION_POLL_INTERVAL__; /** @type {NodeJS.Timeout} */ @@ -226,8 +233,6 @@ export function create_updated_store() { /** @type {() => Promise} */ async function check() { - if (DEV || !BROWSER) return false; - clearTimeout(timeout); if (interval) timeout = setTimeout(check, interval);