(chatId: string)
| 107 | } |
| 108 | |
| 109 | export async function getPendingChatStreamId(chatId: string): Promise<string | null> { |
| 110 | const localEntry = pendingChatStreams.get(chatId) |
| 111 | if (localEntry?.streamId) { |
| 112 | return localEntry.streamId |
| 113 | } |
| 114 | |
| 115 | const redis = getRedisClient() |
| 116 | if (!redis) { |
| 117 | return null |
| 118 | } |
| 119 | |
| 120 | try { |
| 121 | return (await redis.get(getChatStreamLockKey(chatId))) || null |
| 122 | } catch (error) { |
| 123 | logger.warn('Failed to load chat stream lock owner', { |
| 124 | chatId, |
| 125 | error: toError(error).message, |
| 126 | }) |
| 127 | return null |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Loads canonical stream lock owners for chat IDs. |
no test coverage detected