From 6db62d996159d237f875646bbfe0778083a26ff5 Mon Sep 17 00:00:00 2001 From: F4ilji Date: Mon, 6 Jul 2026 21:16:12 +0500 Subject: [PATCH] fix(ssr): suppress lifecycle hook errors (nextSibling null) at process level to prevent SSR crashes --- resources/js/ssr.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/resources/js/ssr.js b/resources/js/ssr.js index bc455d6..23bdd2f 100755 --- a/resources/js/ssr.js +++ b/resources/js/ssr.js @@ -1,3 +1,18 @@ +// Suppress unhandled errors from browser API calls in SSR lifecycle hooks +// (e.g. Inertia Link tries this.$el.nextSibling which is null in SSR) +process.on('unhandledRejection', (reason) => { + if (reason instanceof TypeError && reason.message?.includes('nextSibling')) { + return; // Suppress known SSR lifecycle hook errors + } + console.error('SSR unhandled rejection:', reason); +}); +process.on('uncaughtException', (err) => { + if (err instanceof TypeError && err.message?.includes('nextSibling')) { + return; + } + console.error('SSR uncaught exception:', err); +}); + if (typeof globalThis.IntersectionObserver === 'undefined') { globalThis.IntersectionObserver = class { constructor() {}