feat: capture runtime/preview errors via postMessage and show Fix wit…#51
feat: capture runtime/preview errors via postMessage and show Fix wit…#51
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review WalkthroughThis pull request implements a postMessage-based error reporting system for embedded preview iframes. A new error-bridge script is added to the Astro starter template that captures runtime errors, unhandled promise rejections, and Vite HMR events, normalizing and forwarding them to the parent window. The PreviewPanel component now listens for these error messages, maintains a runtime error state, and renders a conditional overlay displaying error details with a reload button. Errors are cleared on page load, iframe reload, or when the preview URL changes. Sequence DiagramsequenceDiagram
participant Preview as Preview Iframe
participant Bridge as doce-error-bridge.ts
participant Parent as Parent Window
participant Panel as PreviewPanel Component
Preview->>Bridge: error event / unhandledrejection
Bridge->>Bridge: Normalize error & stack
Bridge->>Parent: postMessage({type: 'doce:error', ...})
Parent->>Panel: Receive message
Panel->>Panel: Store in runtimeError state
Panel->>Panel: Render error overlay
Note over Preview,Panel: User clicks reload button
Panel->>Panel: Clear runtimeError state
Panel->>Preview: Reload iframe
Preview->>Bridge: Page loads successfully
Bridge->>Parent: postMessage({type: 'doce:error-clear'})
Parent->>Panel: Receive clear message
Panel->>Panel: Clear runtimeError state
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…h Doce overlay
Summary by CodeRabbit