move-codex-session leaks database connections when a later open throws #139
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
At
1a85c77, several functions inmove-codex-session.tsopen SQLite connections before thetrywhosefinallycloses them. If a later open or setup statement throws, the connections opened so far are never closed.The case from #132 is
deleteSourceDatabases. It opens the source state database, then opens the destination connections inside a.map()(lines 1717-1721), all before thetryat line 1722. If the second or third destination fails to open, the earlier connections stay open. #132 added the two destination connections; #138 reshaped them into this array.The same shape is older (#52) in:
copyState,copyHistoryandcopyThreadDatabase: two opens, thenATTACH,CREATE TEMP TABLEand an insert loop, all before thetry.deleteThreadDatabaseRowsanddeleteDestinationDatabases: the same setup before thetry.verifyDatabaseContentsandverifySourceRemoved: two opens back to back.main: the preflight connections (lines 2075-2083) and the reads after them, with thetryat line 2093.The impact is probably small. The script is a one-shot process that exits after printing the error, and the OS releases the handles then. No effect was measured.
Evidence: code read only. Not reproduced.
A fix would open inside the
tryand close whatever was opened in thefinally.