Repository navigation
fix(desktop): harden renderer boot to avoid white screens #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a37a7c3
Add defensive coding
Kitenite 8c84acd
button
Kitenite f4ee1df
Codex fix
Kitenite 44c9e08
Dark mode
Kitenite a5a098e
Deslop
Kitenite f831ba5
Guard
Kitenite 41c5e07
Refactor
Kitenite 5fd014e
Merge main into kitenite/white-screening
Kitenite 8c62f81
Lint
Kitenite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
apps/desktop/src/renderer/components/BootErrorBoundary/BootErrorBoundary.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import type { ReactNode } from "react"; | ||
| import { Component } from "react"; | ||
|
|
||
| export interface BootErrorBoundaryProps { | ||
| children: ReactNode; | ||
| onError?: (error: Error) => void; | ||
| } | ||
|
|
||
| interface BootErrorBoundaryState { | ||
| hasError: boolean; | ||
| error?: Error; | ||
| } | ||
|
|
||
| export class BootErrorBoundary extends Component< | ||
| BootErrorBoundaryProps, | ||
| BootErrorBoundaryState | ||
| > { | ||
| state: BootErrorBoundaryState = { hasError: false }; | ||
|
|
||
| static getDerivedStateFromError(error: Error): BootErrorBoundaryState { | ||
| return { hasError: true, error }; | ||
| } | ||
|
|
||
| componentDidCatch(error: Error): void { | ||
| console.error("[renderer] Boot error boundary caught:", error); | ||
| this.props.onError?.(error); | ||
| } | ||
|
|
||
| render() { | ||
| if (!this.state.hasError) { | ||
| return this.props.children; | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
| style={{ | ||
| display: "flex", | ||
| height: "100vh", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| background: "#0f0f0f", | ||
| color: "#e5e5e5", | ||
| fontFamily: "system-ui, sans-serif", | ||
| padding: "24px", | ||
| textAlign: "center", | ||
| }} | ||
| > | ||
| <div style={{ maxWidth: "520px" }}> | ||
| <h1 style={{ fontSize: "18px", marginBottom: "8px" }}> | ||
| Superset failed to start | ||
| </h1> | ||
| <p style={{ fontSize: "14px", opacity: 0.8 }}> | ||
| The renderer crashed during startup. Please check logs for details. | ||
| </p> | ||
|
|
||
| <button | ||
| type="button" | ||
| onClick={() => window.location.reload()} | ||
| style={{ | ||
| marginTop: "16px", | ||
| padding: "8px 20px", | ||
| fontSize: "14px", | ||
| background: "#333", | ||
| color: "#e5e5e5", | ||
| border: "1px solid #555", | ||
| borderRadius: "6px", | ||
| cursor: "pointer", | ||
| }} | ||
| > | ||
| Reload | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
apps/desktop/src/renderer/components/BootErrorBoundary/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { BootErrorBoundary } from "./BootErrorBoundary"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| let bootErrorReported = false; | ||
| let hasMounted = false; | ||
| let rootElement: Element | null = null; | ||
| let listenersAttached = false; | ||
|
|
||
| const renderBootError = (message: string, error?: unknown) => { | ||
| if (bootErrorReported) return; | ||
| bootErrorReported = true; | ||
|
|
||
| const container = rootElement ?? document.body; | ||
| const wrapper = document.createElement("div"); | ||
| wrapper.style.display = "flex"; | ||
| wrapper.style.height = "100vh"; | ||
| wrapper.style.alignItems = "center"; | ||
| wrapper.style.justifyContent = "center"; | ||
| wrapper.style.background = "#0f0f0f"; | ||
| wrapper.style.color = "#e5e5e5"; | ||
| wrapper.style.fontFamily = "system-ui, sans-serif"; | ||
| wrapper.style.padding = "24px"; | ||
| wrapper.style.textAlign = "center"; | ||
|
|
||
| const inner = document.createElement("div"); | ||
| inner.style.maxWidth = "520px"; | ||
|
|
||
| const title = document.createElement("div"); | ||
| title.textContent = "Superset failed to start"; | ||
| title.style.fontSize = "18px"; | ||
| title.style.marginBottom = "8px"; | ||
|
|
||
| const detail = document.createElement("div"); | ||
| detail.textContent = message; | ||
| detail.style.fontSize = "14px"; | ||
| detail.style.opacity = "0.8"; | ||
|
|
||
| inner.appendChild(title); | ||
| inner.appendChild(detail); | ||
|
|
||
| if (error) { | ||
| let errorText = "Unknown error"; | ||
| if (error instanceof Error) { | ||
| errorText = error.message; | ||
| } else if (typeof error === "string") { | ||
| errorText = error; | ||
| } else { | ||
| try { | ||
| errorText = JSON.stringify(error); | ||
| } catch { | ||
| errorText = String(error); | ||
| } | ||
| } | ||
| const pre = document.createElement("pre"); | ||
| pre.textContent = errorText; | ||
| pre.style.marginTop = "12px"; | ||
| pre.style.fontSize = "12px"; | ||
| pre.style.opacity = "0.7"; | ||
| pre.style.whiteSpace = "pre-wrap"; | ||
| inner.appendChild(pre); | ||
| } | ||
|
|
||
| wrapper.appendChild(inner); | ||
| container.replaceChildren(wrapper); | ||
| }; | ||
|
|
||
| export const reportBootError = (message: string, error?: unknown) => { | ||
| console.error("[renderer] Boot error:", message, error); | ||
| if (hasMounted) return; | ||
| renderBootError(message, error); | ||
| }; | ||
|
|
||
| const handleGlobalError = (event: ErrorEvent) => { | ||
| if (hasMounted) return; | ||
| reportBootError(event.message || "Unhandled error", event.error); | ||
| }; | ||
|
|
||
| const handleUnhandledRejection = (event: PromiseRejectionEvent) => { | ||
| if (hasMounted) return; | ||
| reportBootError("Unhandled promise rejection", event.reason); | ||
| }; | ||
|
|
||
| export const initBootErrorHandling = (root: Element | null) => { | ||
| rootElement = root; | ||
| if (listenersAttached) return; | ||
| listenersAttached = true; | ||
| window.addEventListener("error", handleGlobalError); | ||
| window.addEventListener("unhandledrejection", handleUnhandledRejection); | ||
| }; | ||
|
|
||
| export const cleanupBootErrorHandling = () => { | ||
| if (!listenersAttached) return; | ||
| listenersAttached = false; | ||
| window.removeEventListener("error", handleGlobalError); | ||
| window.removeEventListener("unhandledrejection", handleUnhandledRejection); | ||
| }; | ||
|
|
||
| export const markBootMounted = () => { | ||
| hasMounted = true; | ||
| }; | ||
|
|
||
| export const isBootErrorReported = () => bootErrorReported; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 2077
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 155
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 91
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 452
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
# Check the electron-trpc.ts to see how tRPC is configured cat -n apps/desktop/src/lib/trpc/electron-trpc.tsRepository: superset-sh/superset
Length of output: 138
🏁 Script executed:
# Check ElectronTRPCProvider cat -n apps/desktop/src/renderer/providers/ElectronTRPCProvider.tsxRepository: superset-sh/superset
Length of output: 156
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 3569
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 1204
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 202
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 1642
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 446
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
# Check the ElectronTRPCProvider to understand how tRPC subscriptions work cat -n apps/desktop/src/renderer/providers/ElectronTRPCProvider/ElectronTRPCProvider.tsxRepository: superset-sh/superset
Length of output: 1272
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 1352
🏁 Script executed:
# Look for the routers index to see what's exported cat -n apps/desktop/src/lib/trpc/routers/index.tsRepository: superset-sh/superset
Length of output: 2277
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 132
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 148
🏁 Script executed:
# Check the main/lib directory structure ls -la apps/desktop/src/main/lib/Repository: superset-sh/superset
Length of output: 2057
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
# Check the menu-events pattern to understand how events are exposed cat -n apps/desktop/src/main/lib/menu-events.tsRepository: superset-sh/superset
Length of output: 541
Route deep-link navigation through a tRPC subscription instead of
window.ipcRenderer.Direct
ipcRendereraccess bypasses the tRPC IPC layer established throughout the codebase. Create adeep-link-events.tsemitter insrc/main/lib/and expose deep-link navigation as a tRPC subscription in the app router (following the pattern used inmenu.ts), then consume it through the tRPC client in the renderer instead.🤖 Prompt for AI Agents