-
Notifications
You must be signed in to change notification settings - Fork 85
fix: stop dashboard refresh loops #1621
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| "@runfusion/fusion": patch | ||
|
|
||
| Revalidate dashboard service-worker assets before falling back to cache so rebuilt tabs cannot stay on stale bundles and render a blank page. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ declare const __BUILD_VERSION__: string; | |||||||||||||||||||
|
|
||||||||||||||||||||
| const RELOAD_FLAG = "fusion:version-reload"; | ||||||||||||||||||||
| const VERSION_UPDATE_FLAG = "fusion:version-update"; | ||||||||||||||||||||
| const RELOADED_REMOTE_VERSION_FLAG = "fusion:version-reloaded-remote"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Module-level guard for auto-reload behavior. | ||||||||||||||||||||
|
|
@@ -30,6 +31,11 @@ export function _resetState(): void { | |||||||||||||||||||
| lastCheckTime = 0; | ||||||||||||||||||||
| checkInFlight = false; | ||||||||||||||||||||
| autoReloadEnabled = true; | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| sessionStorage.removeItem(RELOADED_REMOTE_VERSION_FLAG); | ||||||||||||||||||||
| } catch { | ||||||||||||||||||||
| // ignore | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (pollIntervalId !== null) { | ||||||||||||||||||||
| window.clearInterval(pollIntervalId); | ||||||||||||||||||||
| pollIntervalId = null; | ||||||||||||||||||||
|
|
@@ -65,6 +71,30 @@ export function reloadOnce(reason: string): void { | |||||||||||||||||||
| window.location.reload(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function getReloadedRemoteVersion(): string | null { | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| return sessionStorage.getItem(RELOADED_REMOTE_VERSION_FLAG); | ||||||||||||||||||||
| } catch { | ||||||||||||||||||||
| return null; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function setReloadedRemoteVersion(version: string): void { | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| sessionStorage.setItem(RELOADED_REMOTE_VERSION_FLAG, version); | ||||||||||||||||||||
| } catch { | ||||||||||||||||||||
| // ignore | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function clearReloadedRemoteVersion(): void { | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| sessionStorage.removeItem(RELOADED_REMOTE_VERSION_FLAG); | ||||||||||||||||||||
| } catch { | ||||||||||||||||||||
| // ignore | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export function isStaleChunkError(error: unknown): boolean { | ||||||||||||||||||||
| const message = | ||||||||||||||||||||
| error instanceof Error | ||||||||||||||||||||
|
|
@@ -165,6 +195,7 @@ export async function checkVersion(trigger: VersionCheckTrigger = "initial"): Pr | |||||||||||||||||||
|
|
||||||||||||||||||||
| if (remote === __BUILD_VERSION__) { | ||||||||||||||||||||
| lastMismatchedRemote = null; | ||||||||||||||||||||
| clearReloadedRemoteVersion(); | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -193,11 +224,25 @@ export async function checkVersion(trigger: VersionCheckTrigger = "initial"): Pr | |||||||||||||||||||
| trigger, | ||||||||||||||||||||
| elapsedMs: Date.now() - lastMismatchAt, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (getReloadedRemoteVersion() === remote) { | ||||||||||||||||||||
| pushTrace("versionCheck", "reload-suppressed", { | ||||||||||||||||||||
| remote, | ||||||||||||||||||||
| trigger, | ||||||||||||||||||||
| reason: "already-reloaded-remote-version", | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| console.info("[versionCheck] reload already attempted for remote version", remote); | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try { | ||||||||||||||||||||
| sessionStorage.setItem(VERSION_UPDATE_FLAG, "1"); | ||||||||||||||||||||
| } catch { | ||||||||||||||||||||
| // ignore | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (autoReloadEnabled) { | ||||||||||||||||||||
| setReloadedRemoteVersion(remote); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| reloadOnce(`build version changed: ${__BUILD_VERSION__} -> ${remote}`); | ||||||||||||||||||||
|
Comment on lines
+243
to
246
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| } finally { | ||||||||||||||||||||
| checkInFlight = false; | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
---frontmatter fences — changeset will be silently ignoredThe changeset file is missing the required
---delimiters. Without them the@changesets/cliparser does not recognize this file as a valid changeset, sopnpm releasewill not include this entry in the version bump orCHANGELOG.md. Every other changeset in the repo (e.g.,fix-frozen-dashboard-animations.md) uses the three-line frontmatter pattern.