fix(memory): use response.body.cancel() instead of response.text() for drains

This commit is contained in:
Waleed Latif
2026-03-04 17:00:01 -08:00
parent 2a9df5a821
commit 4dba2a9e77
6 changed files with 6 additions and 6 deletions

View File

@@ -150,7 +150,7 @@ export async function POST(request: NextRequest) {
method: 'GET',
})
if (!response.ok) {
await response.text().catch(() => {})
await response.body?.cancel().catch(() => {})
throw new Error(`Failed to download audio from URL: ${response.statusText}`)
}

View File

@@ -135,7 +135,7 @@ async function fetchDocumentBytes(url: string): Promise<{ bytes: string; content
method: 'GET',
})
if (!response.ok) {
await response.text().catch(() => {})
await response.body?.cancel().catch(() => {})
throw new Error(`Failed to fetch document: ${response.statusText}`)
}

View File

@@ -65,7 +65,7 @@ export async function POST(request: NextRequest) {
})
if (!response.ok) {
await response.text().catch(() => {})
await response.body?.cancel().catch(() => {})
logger.error(`Failed to generate TTS: ${response.status} ${response.statusText}`)
return NextResponse.json(
{ error: `Failed to generate TTS: ${response.status} ${response.statusText}` },

View File

@@ -184,7 +184,7 @@ export async function POST(request: NextRequest) {
method: 'GET',
})
if (!response.ok) {
await response.text().catch(() => {})
await response.body?.cancel().catch(() => {})
return NextResponse.json(
{ success: false, error: 'Failed to fetch image for Gemini' },
{ status: 400 }

View File

@@ -759,7 +759,7 @@ async function markEmailAsRead(accessToken: string, messageId: string) {
})
if (!response.ok) {
await response.text().catch(() => {})
await response.body?.cancel().catch(() => {})
throw new Error(
`Failed to mark email ${messageId} as read: ${response.status} ${response.statusText}`
)

View File

@@ -239,7 +239,7 @@ export async function downloadAttachments(
)
if (!attachmentResponse.ok) {
await attachmentResponse.text().catch(() => {})
await attachmentResponse.body?.cancel().catch(() => {})
continue
}