Skip to content

Commit

Permalink
fix: avoid creating update check timer on the server (#10015)
Browse files Browse the repository at this point in the history
fixes #10005
  • Loading branch information
gtm-nayan authored May 23, 2023
1 parent 1c1ddd5 commit 81af6ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-bulldogs-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: avoid creating update check timer on the server
8 changes: 4 additions & 4 deletions packages/kit/src/runtime/client/singletons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
9 changes: 7 additions & 2 deletions packages/kit/src/runtime/client/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,20 @@ 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} */
let timeout;

/** @type {() => Promise<boolean>} */
async function check() {
if (DEV || !BROWSER) return false;

clearTimeout(timeout);

if (interval) timeout = setTimeout(check, interval);
Expand Down

0 comments on commit 81af6ba

Please sign in to comment.