fix: avoid effect_update_depth_exceeded when clicking flow node on runs page (#8986)

The $effect in useNestedRestartState wrote to selectedJobStepIsTopLevel
and then read it back via the early-return guard. In Svelte 5 that read
registers the same $state as a dependency of the effect, so each write
reschedules the effect → infinite loop.

Compute the boolean into a local const, write it once, and use the local
for the early return.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-04-30 12:16:25 +00:00
committed by GitHub
co-authored by Claude Opus 4.7
parent 8f68f048d8
commit 3ebfc2b0af
@@ -91,8 +91,8 @@ export function useNestedRestartState(opts: {
return
}
selectedJobStepIsTopLevel =
job.flow_status.modules.findIndex((m) => m.id === selectedJobStep) >= 0
const isTopLevel = job.flow_status.modules.findIndex((m) => m.id === selectedJobStep) >= 0
selectedJobStepIsTopLevel = isTopLevel
const moduleDefinition = job.raw_flow?.modules.find((m) => m.id === selectedJobStep)
if (moduleDefinition?.value.type === 'forloopflow') {
selectedJobStepType = 'forloop'
@@ -107,7 +107,10 @@ export function useNestedRestartState(opts: {
selectedJobStepType = 'single'
}
if (selectedJobStepIsTopLevel) return
// Read from the local — reading the `$state` we just wrote would register
// it as a dependency of this effect, causing `effect_update_depth_exceeded`
// because each write would reschedule the effect.
if (isTopLevel) return
// Inline-expanded subflow: id is `subflow:outerStep:[innerSubflow:...]<leaf>`.
// The graph adds the `subflow:` prefix only for subflow expansions, so each