fix(main): cancel unread fetch response bodies so a peer socket close cannot crash the app (#9142)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Jinwoo Hong
2026-07-16 23:10:40 -07:00
committed by GitHub
co-authored by Orca
parent 23368ee9da
commit d0b090b0ff
16 changed files with 283 additions and 0 deletions
@@ -1,5 +1,6 @@
import { Buffer } from 'node:buffer'
import type { AzureDevOpsRepoRef } from './repository-ref'
import { cancelUnreadResponseBody } from '../lib/unread-response-body'
const REQUEST_TIMEOUT_MS = 5000
@@ -84,6 +85,7 @@ export async function requestAzureDevOpsJsonAtBase<T>(
signal: AbortSignal.timeout(options.timeoutMs ?? REQUEST_TIMEOUT_MS)
})
if (!response.ok) {
await cancelUnreadResponseBody(response)
return null
}
return (await response.json()) as T