Skip to content

Commit 187db39

Browse files
committed
prune invalid refs when adding new ones
1 parent 61d0095 commit 187db39

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

api/src/DuckDBPreparedStatementWeakRefCollection.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class DuckDBPreparedStatementWeakRefCollection
66
{
77
preparedStatements: WeakRef<DuckDBPreparedStatement>[] = [];
88
public add(prepared: DuckDBPreparedStatement) {
9+
this.prune();
910
this.preparedStatements.push(new WeakRef(prepared));
1011
}
1112
public destroySync() {
@@ -17,4 +18,9 @@ export class DuckDBPreparedStatementWeakRefCollection
1718
}
1819
this.preparedStatements = [];
1920
}
21+
private prune() {
22+
this.preparedStatements = this.preparedStatements.filter(
23+
(ref) => !!ref.deref()
24+
);
25+
}
2026
}

0 commit comments

Comments
 (0)