fix: make sessionExists() async with SDK verification on SQLite
sessionExists() previously returned unconditional true on SQLite, preventing ralph-loop orphaned-session cleanup from triggering. Now uses sdkClient.session.messages() to verify session actually exists. Callers updated to await the async result. Addresses Cubic review feedback on PR #1837.
This commit is contained in:
@@ -78,15 +78,15 @@ describe("session-manager storage", () => {
|
||||
expect(result).toBe(sessionPath)
|
||||
})
|
||||
|
||||
test("sessionExists returns false for non-existent session", () => {
|
||||
test("sessionExists returns false for non-existent session", async () => {
|
||||
// when
|
||||
const exists = sessionExists("ses_nonexistent")
|
||||
const exists = await sessionExists("ses_nonexistent")
|
||||
|
||||
// then
|
||||
expect(exists).toBe(false)
|
||||
})
|
||||
|
||||
test("sessionExists returns true for existing session", () => {
|
||||
test("sessionExists returns true for existing session", async () => {
|
||||
// given
|
||||
const sessionID = "ses_exists"
|
||||
const sessionPath = join(TEST_MESSAGE_STORAGE, sessionID)
|
||||
@@ -94,7 +94,7 @@ describe("session-manager storage", () => {
|
||||
writeFileSync(join(sessionPath, "msg_001.json"), JSON.stringify({ id: "msg_001" }))
|
||||
|
||||
// when
|
||||
const exists = sessionExists(sessionID)
|
||||
const exists = await sessionExists(sessionID)
|
||||
|
||||
// then
|
||||
expect(exists).toBe(true)
|
||||
|
||||
Reference in New Issue
Block a user