From 120c88028f6d2026c8fab2daabf1b9e73321d912 Mon Sep 17 00:00:00 2001 From: John Obelenus Date: Mon, 8 Dec 2025 16:17:54 -0500 Subject: [PATCH] web experience backstop & telemetry there is an outside chance that the system will fail to send a wsevent (incident, poor timing of a deploy, etc etc) to the web worker that tells it the index has been built successfully so we have a backup cold start interval here to prevent a user from being stuck in the lobby perpetually make sure we end a span in a no-op case bring back a disconnect notification for only SI cohort emit span events for when we open and close ws connections every 30 seconds, if we have not gotten index update messages, try to cold start, just in case this is a fail safe for clients that are not receiving messages. yes, in a quiet workspace this will make calls that result in nothing much happening. but its hitting a cache and its a small price to pay. 30 seconds might be the wrong number, but its something. --- app/web/src/newhotness/Workspace.vue | 42 +++++++-- .../src/newhotness/nav/NavbarPanelCenter.vue | 9 +- app/web/src/newhotness/util.ts | 46 ---------- app/web/src/store/feature_flags.store.ts | 1 + app/web/src/store/realtime/heimdall.ts | 90 +++++++++++++++--- app/web/src/workers/shared_webworker.ts | 17 ++++ app/web/src/workers/types/dbinterface.ts | 4 + app/web/src/workers/utils.ts | 92 +++++++++++++++++++ app/web/src/workers/webworker.ts | 51 +++++++--- 9 files changed, 273 insertions(+), 79 deletions(-) create mode 100644 app/web/src/workers/utils.ts diff --git a/app/web/src/newhotness/Workspace.vue b/app/web/src/newhotness/Workspace.vue index 917fa84845..fab521ffa3 100644 --- a/app/web/src/newhotness/Workspace.vue +++ b/app/web/src/newhotness/Workspace.vue @@ -33,7 +33,7 @@ :changeSetId="changeSetId" :componentId="componentId" :viewId="viewId" - connected + :connected="haveWSConn" /> @@ -236,10 +236,9 @@ const changeSetId = computed(() => props.changeSetId); const coldStartInProgress = computed(() => heimdall.muspelheimInProgress.value); -// const haveWSConn = computed(() => { -// if (!heimdall.initCompleted.value) return true; // dont show error if we havent gotten started -// return !!heimdall.wsConnections.value[props.workspacePk]; -// }); +const haveWSConn = computed(() => { + return !!heimdall.wsConnections.value[props.workspacePk]; +}); // no tan stack queries hitting sqlite until after the cold start has finished const queriesEnabled = computed( @@ -637,11 +636,42 @@ watch( return; } await heimdall.registerBearerToken(newWorkspacePk, workspaceToken); - heimdall.niflheim(newWorkspacePk, newChangeSetId, true, false); + await heimdall.niflheim(newWorkspacePk, newChangeSetId, true, false); } }, ); +const EVENTUALLY_CONSISTENT_TIME = 30 * 1000; // 30 seconds +let indexInterval: NodeJS.Timeout; + +watch( + () => [props.changeSetId], + () => { + // clear any interval for other change set + if (indexInterval) clearInterval(indexInterval); + + // set a new interval (note: above watcher fires first cold start from the user selection change) + indexInterval = setInterval(() => { + heimdall.syncAtoms(props.workspacePk, props.changeSetId); + }, EVENTUALLY_CONSISTENT_TIME); + }, + { immediate: true }, +); + +watch( + () => heimdall.indexTouches.get(props.changeSetId), + () => { + if (lobby.value) return; // dont do anything when in the lobby + // each time we get index updates, clear the interval + if (indexInterval) clearInterval(indexInterval); + // and restart it + indexInterval = setInterval(() => { + heimdall.syncAtoms(props.workspacePk, props.changeSetId); + }, EVENTUALLY_CONSISTENT_TIME); + }, + { immediate: true }, +); + const indexFailedToLoad = computed(() => { // NOTE: this represents a 5XX error that was retried 5 times // if we get here its likely because the index could not be retrieved, or even built diff --git a/app/web/src/newhotness/nav/NavbarPanelCenter.vue b/app/web/src/newhotness/nav/NavbarPanelCenter.vue index 41474aa339..d7a3a363c3 100644 --- a/app/web/src/newhotness/nav/NavbarPanelCenter.vue +++ b/app/web/src/newhotness/nav/NavbarPanelCenter.vue @@ -2,7 +2,7 @@
-