MCPcopy Index your code
hub / github.com/simstudioai/sim / getChatStreamLockOwners

Function getChatStreamLockOwners

apps/sim/lib/copilot/request/session/abort.ts:139–173  ·  view source on GitHub ↗
(
  chatIds: string[]
)

Source from the content-addressed store, hash-verified

137 * in a multi-pod deployment.
138 */
139export async function getChatStreamLockOwners(
140 chatIds: string[]
141): Promise<ChatStreamLockOwnersResult> {
142 const localOwnersByChatId = new Map<string, string>()
143 if (chatIds.length === 0) {
144 return { status: 'verified', ownersByChatId: localOwnersByChatId }
145 }
146
147 for (const chatId of chatIds) {
148 const entry = pendingChatStreams.get(chatId)
149 if (entry?.streamId) localOwnersByChatId.set(chatId, entry.streamId)
150 }
151
152 const redis = getRedisClient()
153 if (!redis) {
154 return { status: 'unknown', ownersByChatId: localOwnersByChatId }
155 }
156
157 try {
158 const keys = chatIds.map(getChatStreamLockKey)
159 const values = await redis.mget(keys)
160 const redisOwnersByChatId = new Map<string, string>()
161 for (let i = 0; i < chatIds.length; i++) {
162 const owner = values[i]
163 if (owner) redisOwnersByChatId.set(chatIds[i], owner)
164 }
165 return { status: 'verified', ownersByChatId: redisOwnersByChatId }
166 } catch (error) {
167 logger.warn('Failed to load chat stream lock owners (batch)', {
168 count: chatIds.length,
169 error: toError(error).message,
170 })
171 return { status: 'unknown', ownersByChatId: localOwnersByChatId }
172 }
173}
174
175export async function releasePendingChatStream(chatId: string, streamId: string): Promise<void> {
176 try {

Callers 2

abort.test.tsFile · 0.90

Calls 5

getRedisClientFunction · 0.90
toErrorFunction · 0.90
getMethod · 0.65
setMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected