diff --git a/.changeset/silver-elephants-attack.md b/.changeset/silver-elephants-attack.md new file mode 100644 index 000000000000..53051f803c61 --- /dev/null +++ b/.changeset/silver-elephants-attack.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Prevent unhandled rejections when loading page modules diff --git a/packages/kit/src/runtime/client/client.js b/packages/kit/src/runtime/client/client.js index 9a4870b8b524..e93adf671da3 100644 --- a/packages/kit/src/runtime/client/client.js +++ b/packages/kit/src/runtime/client/client.js @@ -612,8 +612,10 @@ export function create_client({ target, session, base, trailing_slash }) { /** @type {Error | null} */ let error = null; - // preload modules - a.forEach((loader) => loader()); + // preload modules to avoid waterfall, but handle rejections + // so they don't get reported to Sentry et al (we don't need + // to act on the failures at this point) + a.forEach((loader) => loader().catch(() => {})); load: for (let i = 0; i < a.length; i += 1) { /** @type {import('./types').BranchNode | undefined} */