diff --git a/services/backend/src/modules/messages/messages.repository.ts b/services/backend/src/modules/messages/messages.repository.ts index a812e33..bdb35a6 100644 --- a/services/backend/src/modules/messages/messages.repository.ts +++ b/services/backend/src/modules/messages/messages.repository.ts @@ -77,12 +77,11 @@ export class MessagesRepository { // Exclude spam threads (NULL-safe: non-thread messages are kept) if (EXCLUDED_THREAD_IDS.length > 0) { - conditions.push( - or( - isNull(pgMessagesTable.thread_id), - notInArray(pgMessagesTable.thread_id, EXCLUDED_THREAD_IDS), - )!, + const excludeThreads = or( + isNull(pgMessagesTable.thread_id), + notInArray(pgMessagesTable.thread_id, EXCLUDED_THREAD_IDS), ); + if (excludeThreads) conditions.push(excludeThreads); } const where = conditions.length > 0 ? and(...conditions) : undefined; @@ -150,12 +149,11 @@ export class MessagesRepository { // Exclude spam threads (NULL-safe) if (EXCLUDED_THREAD_IDS.length > 0) { - conditions.push( - or( - isNull(pgMessagesTable.thread_id), - notInArray(pgMessagesTable.thread_id, EXCLUDED_THREAD_IDS), - )!, + const excludeThreads = or( + isNull(pgMessagesTable.thread_id), + notInArray(pgMessagesTable.thread_id, EXCLUDED_THREAD_IDS), ); + if (excludeThreads) conditions.push(excludeThreads); } const rows = await db @@ -316,12 +314,13 @@ export class MessagesRepository { like(pgAttachmentsTable.type, "image/%"), // Exclude spam threads (NULL-safe for non-thread messages) ...(EXCLUDED_THREAD_IDS.length > 0 - ? [ - or( + ? (() => { + const excludeThreads = or( isNull(pgAttachmentsTable.thread_id), notInArray(pgAttachmentsTable.thread_id, EXCLUDED_THREAD_IDS), - )!, - ] + ); + return excludeThreads ? [excludeThreads] : []; + })() : []), ), ) diff --git a/services/discord-gateway/src/goLive/BaseMediaConnection.ts b/services/discord-gateway/src/goLive/BaseMediaConnection.ts index 7509656..f93615b 100644 --- a/services/discord-gateway/src/goLive/BaseMediaConnection.ts +++ b/services/discord-gateway/src/goLive/BaseMediaConnection.ts @@ -652,11 +652,7 @@ a=ice-lite * CONNECTING) breaks GoLive video while leaving audio intact. We wait for * the open state instead of dropping. */ - private sendOpcodeWhenOpen( - code: number, - data: unknown, - label: string, - ): void { + private sendOpcodeWhenOpen(code: number, data: unknown, label: string): void { const attempt = (triesLeft: number) => { if (this.ws?.readyState === WebSocket.OPEN) { this.sendOpcode(code, data); diff --git a/services/discord-gateway/src/shared/utils/index.ts b/services/discord-gateway/src/shared/utils/index.ts index 83ceba9..12bd541 100644 --- a/services/discord-gateway/src/shared/utils/index.ts +++ b/services/discord-gateway/src/shared/utils/index.ts @@ -108,5 +108,8 @@ export async function retryWithBackoff( }); } } - throw lastError!; + // lastError is always set: the for-loop only exits via break when attempt + // === retries, which only happens in the catch branch that sets lastError. + if (!lastError) throw new Error("Unknown retry error"); + throw lastError; }