From dfcbc3d0d5d47cfca7232c38e5cfa10c0184e7c6 Mon Sep 17 00:00:00 2001 From: clockwork-labs-bot Date: Fri, 6 Mar 2026 15:28:00 -0500 Subject: [PATCH 1/3] Fix useTable isReady reverting to false after first row event (#4559) The subscribe callback passed to useSyncExternalStore captured computeSnapshot in its closure but did not list it as a dependency. When subscribeApplied flipped to true, computeSnapshot was recreated with the new value, but subscribe still held the stale closure that permanently captured subscribeApplied = false. Adding computeSnapshot to subscribe's dependency array ensures the event handlers always call the current computeSnapshot, so isReady stays true after onApplied fires. --- crates/bindings-typescript/src/react/useTable.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bindings-typescript/src/react/useTable.ts b/crates/bindings-typescript/src/react/useTable.ts index 5d3c1edd86c..bcb21004a63 100644 --- a/crates/bindings-typescript/src/react/useTable.ts +++ b/crates/bindings-typescript/src/react/useTable.ts @@ -210,6 +210,7 @@ export function useTable( connectionState, accessorName, querySql, + computeSnapshot, callbacks?.onDelete, callbacks?.onInsert, callbacks?.onUpdate, From de279e4c6e6b3e0bee52ba5271b5d87bfde5526f Mon Sep 17 00:00:00 2001 From: Zeke Foppa <196249+bfops@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:17:23 -0700 Subject: [PATCH 2/3] Apply suggestion from @bfops Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> --- crates/bindings-typescript/src/react/useTable.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bindings-typescript/src/react/useTable.ts b/crates/bindings-typescript/src/react/useTable.ts index bcb21004a63..ce674c4bbc4 100644 --- a/crates/bindings-typescript/src/react/useTable.ts +++ b/crates/bindings-typescript/src/react/useTable.ts @@ -205,6 +205,8 @@ export function useTable( table.removeOnUpdate?.(onUpdate); }; }, + // TODO: investigating refactoring so that this is no longer necessary, as we have had genuine bugs with missed deps. + // See https://github.com/clockworklabs/SpacetimeDB/pull/4580. // eslint-disable-next-line react-hooks/exhaustive-deps [ connectionState, From 671c1b675e279b9444b2fef5a2b0355e34f9e7fe Mon Sep 17 00:00:00 2001 From: Zeke Foppa <196249+bfops@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:17:52 -0700 Subject: [PATCH 3/3] Apply suggestion from @bfops Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> --- crates/bindings-typescript/src/react/useTable.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bindings-typescript/src/react/useTable.ts b/crates/bindings-typescript/src/react/useTable.ts index ce674c4bbc4..6eb5e0cf209 100644 --- a/crates/bindings-typescript/src/react/useTable.ts +++ b/crates/bindings-typescript/src/react/useTable.ts @@ -104,6 +104,8 @@ export function useTable( ) as Prettify[]) : (Array.from(table.iter()) as Prettify[]); return [result, subscribeApplied]; + // TODO: investigating refactoring so that this is no longer necessary, as we have had genuine bugs with missed deps. + // See https://github.com/clockworklabs/SpacetimeDB/pull/4580. // eslint-disable-next-line react-hooks/exhaustive-deps }, [connectionState, accessorName, querySql, subscribeApplied]);