Skip to content

Commit 25d3695

Browse files
fuzzie360claude
andcommitted
fix: surface boot failures instead of a silent blank page
In-app browsers (a Telegram blank-page report prompted this) can fail the app boot with no visible signal. An ES5 inline reporter now captures the first error / failed asset load and, if the root never mounts, shows a panel with the error, an open-in-your-browser hint, and the feedback link. Propagates to every prerendered page via the shared shell. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RJujXBsBhXBbQ72tS7E7GV
1 parent 95030e9 commit 25d3695

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎index.html‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,46 @@
2828
}
2929
})();
3030
</script>
31+
<script>
32+
// Boot-failure reporter. If the app never mounts (in-app browsers are
33+
// the usual culprits — see the Telegram blank-page report), show what
34+
// went wrong instead of a silent dark page. ES5 on purpose: this must
35+
// run on engines too old for the main bundle, which is exactly when a
36+
// syntax-level failure would otherwise be invisible.
37+
(function () {
38+
var firstError = null;
39+
function remember(message) {
40+
if (!firstError && message) firstError = String(message).slice(0, 300);
41+
}
42+
window.addEventListener('error', function (e) {
43+
remember(e.message || (e.target && e.target.src && 'failed to load ' + e.target.src));
44+
}, true);
45+
window.addEventListener('unhandledrejection', function (e) {
46+
remember(e.reason && (e.reason.message || e.reason));
47+
});
48+
function check(finalTry) {
49+
var root = document.getElementById('root');
50+
if (!root || root.childNodes.length > 0) return; // mounted — all good
51+
if (!firstError && !finalTry) { setTimeout(function () { check(true); }, 8000); return; }
52+
var panel = document.createElement('div');
53+
panel.setAttribute('style',
54+
'position:fixed;left:12px;right:12px;bottom:12px;z-index:99999;' +
55+
'background:#171040;color:#f6f7f8;border:1px solid #ff79c6;border-radius:10px;' +
56+
'padding:14px 16px;font:14px/1.5 -apple-system,system-ui,sans-serif;');
57+
panel.innerHTML =
58+
'<b>This page failed to start.</b><br>' +
59+
(firstError
60+
? '<code style="font-size:12px;word-break:break-all;color:#ff79c6;">' +
61+
firstError.replace(/&/g, '&amp;').replace(/</g, '&lt;') + '</code><br>'
62+
: '') +
63+
'If you are in an in-app browser (Telegram, Instagram…), try ' +
64+
'“Open in Browser” from its menu. ' +
65+
'<a href="https://github.com/gpujs/gpu.rocks/issues/31" style="color:#20a4f3;">Report this</a>';
66+
document.body.appendChild(panel);
67+
}
68+
setTimeout(function () { check(false); }, 7000);
69+
})();
70+
</script>
3171
<!-- Dev-server defaults only: scripts/prerender.mjs strips these from the
3272
built shell and injects the full per-route set (routeMeta.js values). -->
3373
<meta property="og:title" content="GPU.js — GPU accelerated JavaScript">

0 commit comments

Comments
 (0)