fix(canvas): never leave a canvas blank when its sandbox fails to load - #3975
Draft
posthog[bot] wants to merge 1 commit into
Draft
fix(canvas): never leave a canvas blank when its sandbox fails to load#3975posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
A canvas renders inside a sandboxed iframe whose bootstrap statically imported the transpiler from the CDN. When that fetch failed, the whole bootstrap module was discarded — taking the error handlers and the "ready" handshake with it — so the sandbox posted nothing at all and the host had no way to tell a failed boot apart from a canvas that simply had not rendered. The result was a permanently blank surface: no message, no retry, and in view mode (no toolbar) no affordance whatsoever. A fresh document was the only way out, which is why relaunching the app appeared to fix it. - Load the transpiler and React lazily and register the sandbox's error reporting before anything that can fail, so a CDN failure is reported instead of silently killing the bootstrap. - Add a boot watchdog on the host so a boot that stalls without erroring is bounded rather than blank forever. - Track whether a canvas has ever rendered, and when it has not, show a recoverable error state (Try again / Ask agent to fix) instead of an empty viewport. "Try again" recreates the frame, which is what actually recovers — a failed module fetch is cached in the document's module map. - Give canvas thumbnails the same treatment, so a preview that never painted says so instead of looking like an empty canvas. Generated-By: PostHog Code Task-Id: a741aee3-3442-431b-b984-28bc75a3b824
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Canvases could load as a completely blank screen — no message, no spinner, nothing to click — and relaunching the app would sometimes bring them back. Raised in #team-canvas and reproduced by two people, on the billing Canvas and then on a second one.
Root cause: a canvas renders inside a sandboxed iframe whose bootstrap statically imported the transpiler from the CDN. If that fetch failed, the whole bootstrap module was discarded — and with it the sandbox's error handlers and its
readyhandshake. The host therefore received no message at all, and had no way to tell "the runtime never loaded" from "this canvas hasn't rendered yet", so it just showed an empty frame forever. In view mode there is no toolbar, so there was not even an error chip. Recreating the document was the only escape, which is why relaunching appeared to fix it.Reproduced by loading the real sandbox document with the CDN host unreachable: the iframe's
loadevent fires,#rootstays empty, and the host receives zero messages.Changes
How did you test this?
#rootempty, host receives[]— a blank surface;["ready", {type: "error", …}]and renders the error state;initin the same document still fails (module map is poisoned), while recreating the frame yields["ready", "rendered"]and the canvas paints — confirming Try again must, and does, recreate the frame.CanvasErrorStatecomponent. Screenshots are attached to the originating thread.pnpm --filter @posthog/ui test— 2392 passed, including new tests for the sandbox bootstrap ordering, the boot watchdog, the render-health store transitions, and the error component.pnpm --filter @posthog/ui typecheck,pnpm lintclean.Not addressed here: the separate report of a canvas's data refresh failing after it renders. That path already surfaces an error notice rather than a blank screen, so it needs its own investigation.
Automatic notifications
Created with PostHog Desktop from this inbox report.