Skip to content

Commit

Permalink
Fix race condition on cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaHegde committed Dec 12, 2024
1 parent 6b526ae commit 7c3ce36
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { onNavigate } from "$app/navigation";
import { afterNavigate, onNavigate } from "$app/navigation";
import { page } from "$app/stores";
import DashboardBuilding from "@rilldata/web-admin/features/dashboards/DashboardBuilding.svelte";
import DashboardErrored from "@rilldata/web-admin/features/dashboards/DashboardErrored.svelte";
Expand All @@ -12,6 +12,7 @@
import { useExplore } from "@rilldata/web-common/features/explores/selectors";
import { eventBus } from "@rilldata/web-common/lib/event-bus/event-bus";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import type { AfterNavigate } from "@sveltejs/kit";
import type { PageData } from "./$types";
const PollIntervalWhenDashboardFirstReconciling = 1000;
Expand Down Expand Up @@ -82,6 +83,12 @@
});
}
let previousNavigationType: AfterNavigate["type"];
afterNavigate(({ from, type }) => {
if (from !== null && !from.url) return;
previousNavigationType = type;
});
onNavigate(() => {
// Temporary: clear the mocked user when navigating away.
// In the future, we should be able to handle the mocked user on all project pages.
Expand Down Expand Up @@ -110,6 +117,7 @@
{exploreStateFromYAMLConfig}
{partialExploreStateFromUrl}
{exploreStateFromSessionStorage}
{previousNavigationType}
>
<DashboardThemeProvider>
<Dashboard {metricsViewName} {exploreName} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
metricsViewName,
exploreName,
extraKeyPrefix:
orgName && projectName ? `__${orgName}__${projectName}` : "",
orgName && projectName ? `${orgName}__${projectName}__` : "",
});
setContext(DEFAULT_STORE_KEY, stateManagers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
} from "@rilldata/web-common/runtime-client";
import type { HTTPError } from "@rilldata/web-common/runtime-client/fetchWrapper";
import { runtime } from "@rilldata/web-common/runtime-client/runtime-store";
import type { AfterNavigate } from "@sveltejs/kit";
import { onMount } from "svelte";
export let metricsViewName: string;
export let exploreName: string;
Expand All @@ -24,6 +26,7 @@
export let exploreStateFromSessionStorage:
| Partial<MetricsExplorerEntity>
| undefined;
export let previousNavigationType: AfterNavigate["type"];
const { dashboardStore, validSpecStore, timeRangeSummaryStore } =
getStateManagers();
Expand Down Expand Up @@ -127,6 +130,13 @@
$: if ($dashboardStore) {
gotoNewState();
}
onMount(() => {
// safeguard to make sure we initialize the explore state in case afterNavigate is missed
if (!$dashboardStore) {
handleExploreInit(previousNavigationType === "enter");
}
});
</script>

{#if schemaError}
Expand Down
1 change: 0 additions & 1 deletion web-common/src/features/explores/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from "@rilldata/web-common/runtime-client";
import type { ErrorType } from "@rilldata/web-common/runtime-client/http-client";
import { error } from "@sveltejs/kit";
import type { Part } from "@sveltejs/kit/src/core/sync/create_manifest_data/types";

export function useExplore(
instanceId: string,
Expand Down

0 comments on commit 7c3ce36

Please sign in to comment.