8000 fix stale transaction error · githubocto/flat-viewer@e0b17f4 · GitHub
[go: up one dir, main page]

Skip to content

Commit e0b17f4

Browse files
author
Matt Rothenberg
committed
fix stale transaction error
1 parent 12955b2 commit e0b17f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/db-explorer.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const VALID_EXTENSIONS = ["csv", "json"];
2828

2929
function DBExplorerInner(props: DBExplorerInnerProps) {
3030
const { content, extension, filename, sha } = props;
31-
const connectionRef = useRef<duckdb.AsyncDuckDBConnection>();
31+
const connectionRef = useRef<duckdb.AsyncDuckDBConnection | null>(null);
3232
const [query, setQuery] = useState("");
3333
const [debouncedQuery] = useDebounce(query, 500);
3434
const [dbStatus, setDbStatus] = useState<"error" | "idle" | "success">(
@@ -98,9 +98,11 @@ function DBExplorerInner(props: DBExplorerInnerProps) {
9898
return () => {
9999
if (connectionRef.current) {
100100
connectionRef.current.close();
101+
connectionRef.current = null;
102+
setDbStatus("idle");
101103
}
102104
};
103-
}, [content]);
105+
}, [content, sha, filename]);
104106

105107
const sqlSchema = useMemo(() => {
106108
if (!content) return [];

0 commit comments

Comments
 (0)
0