Skip to content

Commit bcfbcac

Browse files
committed
fix: should prevent frozen thread to receive new message
1 parent b19e1ca commit bcfbcac

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • apps/backend-convex/convex/http

apps/backend-convex/convex/http/ai.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ aiApp
9999

100100
// Cast type and runQuery to check for permission
101101
const threadId = _threadId as Id<'threads'>
102-
const _thread = await c.env.runQuery(api.threads.get, { threadId, lockerKey })
102+
const thread = await c.env.runQuery(api.threads.get, { threadId, lockerKey })
103103

104104
let streamId: string
105105
let streamingMessageId: Id<'messages'>
@@ -133,6 +133,9 @@ aiApp
133133
}
134134
}
135135
else if (content) {
136+
if (thread.frozen)
137+
throw new ConvexError(`Can't send new messages to frozen thread`)
138+
136139
// Create new streaming session
137140
streamId = `${Date.now()}_${randomStr(10)}`
138141

0 commit comments

Comments
 (0)