From c317cfb4203d36fd45e99f7ca5ead20a343fbe24 Mon Sep 17 00:00:00 2001 From: MythEclipse Date: Sun, 14 Jun 2026 01:17:18 +0700 Subject: [PATCH] fix(ci): resolve TS build errors across all services - recordings.routes.ts: cast req.params.id to string (express 5 typed params) - recordings.service.ts: cast Record[] via unknown first - guilds.routes.ts: cast req.params.guildId to string (2 sites) - transmitter.ts: capture pcmStream ref locally + re-acquire in drain callback Co-Authored-By: Claude --- .../src/modules/recordings/recordings.routes.ts | 2 +- .../src/modules/recordings/recordings.service.ts | 2 +- services/backend/src/modules/voice/guilds.routes.ts | 4 ++-- .../src/modules/voice-recording/transmitter.ts | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/services/backend/src/modules/recordings/recordings.routes.ts b/services/backend/src/modules/recordings/recordings.routes.ts index 3039f61..b30efc9 100644 --- a/services/backend/src/modules/recordings/recordings.routes.ts +++ b/services/backend/src/modules/recordings/recordings.routes.ts @@ -31,7 +31,7 @@ export function createRecordingsRouter(): Router { router.delete( "/recordings/:id", asyncHandler(async (req: Request, res: Response) => { - const { id } = req.params; + const id = req.params.id as string; await recordingsService.deleteById(id); res.json({ ok: true }); }), diff --git a/services/backend/src/modules/recordings/recordings.service.ts b/services/backend/src/modules/recordings/recordings.service.ts index 08a9706..ae512da 100644 --- a/services/backend/src/modules/recordings/recordings.service.ts +++ b/services/backend/src/modules/recordings/recordings.service.ts @@ -68,7 +68,7 @@ export class RecordingsService { LIMIT ${limit + 1} `); - const items = rows.slice(0, limit) as RecordingRow[]; + const items = rows.slice(0, limit) as unknown as RecordingRow[]; const hasMore = rows.length > limit; const nextCursor = hasMore ? String(items[items.length - 1]!.created_at) : null; diff --git a/services/backend/src/modules/voice/guilds.routes.ts b/services/backend/src/modules/voice/guilds.routes.ts index 02a5361..14c3a09 100644 --- a/services/backend/src/modules/voice/guilds.routes.ts +++ b/services/backend/src/modules/voice/guilds.routes.ts @@ -27,7 +27,7 @@ export function createGuildsRouter(): Router { router.get( "/:guildId/channels", asyncHandler(async (req: Request, res: Response) => { - const guildId = req.params.guildId; + const guildId = req.params.guildId as string; logger.debug({ guildId }, "Fetching text channels"); const channels = await getTextChannels(guildId); res.json(channels); @@ -38,7 +38,7 @@ export function createGuildsRouter(): Router { router.get( "/:guildId/voice-channels", asyncHandler(async (req: Request, res: Response) => { - const guildId = req.params.guildId; + const guildId = req.params.guildId as string; logger.debug({ guildId }, "Fetching voice channels"); const channels = await getVoiceChannels(guildId); res.json(channels); diff --git a/services/discord-gateway/src/modules/voice-recording/transmitter.ts b/services/discord-gateway/src/modules/voice-recording/transmitter.ts index 47daac3..38c8929 100644 --- a/services/discord-gateway/src/modules/voice-recording/transmitter.ts +++ b/services/discord-gateway/src/modules/voice-recording/transmitter.ts @@ -133,16 +133,20 @@ export class VoiceTransmitter { const data = JSON.parse(message); if (data.type === "pcm" && data.buffer) { const pcmBuffer = Buffer.from(data.buffer, "base64"); - const canContinue = this.pcmStream.write(pcmBuffer); + const stream = this.pcmStream; + const canContinue = stream.write(pcmBuffer); // Backpressure: queue until drain if (!canContinue) { this.draining = true; - this.pcmStream.once("drain", () => { + stream.once("drain", () => { this.draining = false; + // Re-acquire stream reference (could have been replaced by restart) + const currentStream = this.pcmStream; + if (!currentStream) return; // Flush queued chunks while (this.backpressureQueue.length > 0) { const queued = this.backpressureQueue.shift()!; - if (!this.pcmStream.write(queued)) break; + if (!currentStream.write(queued)) break; } }); }