From a74452f46e925889b22ea5027af2b96f611edcd9 Mon Sep 17 00:00:00 2001 From: Kaan Date: Mon, 19 Oct 2026 17:18:47 +0300 Subject: [PATCH] Fix effect updating its own source looping in strict mode --- src/graph.luau | 2 +- test/tests.luau | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/graph.luau b/src/graph.luau index 516ac89..be76dc1 100644 --- a/src/graph.luau +++ b/src/graph.luau @@ -175,7 +175,7 @@ local update_queue = { n = 0 } :: { n: number, [number]: Node } local function try_evaluate_node(node: Node): (boolean, string?) if flags.strict then if table.find(scopes, node) then - error("a scope, that should rerun due to the update of a source, is already active", 0) + return false, "a scope, that should rerun due to the update of a source, is already active" end local initial_value = node.cache diff --git a/test/tests.luau b/test/tests.luau index 548a974..dd07517 100644 --- a/test/tests.luau +++ b/test/tests.luau @@ -3171,6 +3171,21 @@ TEST("strict", wrap_root(function() CHECK(count == 4) end + do CASE "effect updating its own source" + local src = source(0) + local count = 0 + + effect(function() + count += 1 + if count > 100 then return end + local v = src() + if v > 0 then src(v + 1) end + end) + + CHECK(not pcall(src, 1)) + CHECK(count < 100) + end + do CASE "destruction of active scope" local src = source(false) local count = 0