mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Fix preview pane getting stuck during auto-refresh on rapid builds
The refresh mechanism posted a JSON-RPC `refresh` command to the nested iframe.diy frames. During rapid build cycles, the command could be silently dropped when the inner iframe was mid-reload, not yet mounted, or when the outer frame's handshake was still pending \u2014 leaving the preview stuck on a stale build with no way to recover short of reloading the whole page. Switch to remounting the iframe via a React key bump, which always works regardless of handshake state. Also fix a bug in the injected preview script where `++rpcId` (a function) silently corrupted the id generator to NaN, breaking navigation state and uncaught error reporting.
This commit is contained in:
2 files changed
+18
-6
No files matched your search
@@ -142,7 +142,7 @@ export function getPreviewInjectedScript(): string {
|
||||
try {
|
||||
window.parent.postMessage({
|
||||
jsonrpc: '2.0',
|
||||
id: ++rpcId,
|
||||
id: rpcId(),
|
||||
method: 'updateNavigationState',
|
||||
params: {
|
||||
currentUrl: semanticPath,
|
||||
@@ -259,7 +259,7 @@ export function getPreviewInjectedScript(): string {
|
||||
try {
|
||||
window.parent.postMessage({
|
||||
jsonrpc: '2.0',
|
||||
id: ++rpcId,
|
||||
id: rpcId(),
|
||||
method: 'console',
|
||||
params: {
|
||||
level: 'error',
|
||||
@@ -279,7 +279,7 @@ export function getPreviewInjectedScript(): string {
|
||||
try {
|
||||
window.parent.postMessage({
|
||||
jsonrpc: '2.0',
|
||||
id: ++rpcId,
|
||||
id: rpcId(),
|
||||
method: 'console',
|
||||
params: {
|
||||
level: 'error',
|
||||
|
||||
Reference in new issue
Block a user