Skip to content

Commit 4295c23

Browse files
committed
fix(data-drains): drain datadog and bigquery probe success bodies
Same undici keep-alive issue as the prior fixes: postWithRetries returned the Response on success without draining (callers only read headers); the BigQuery `test()` probe returned without consuming the body. Both now drain before returning.
1 parent b0e714d commit 4295c23

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

apps/sim/lib/data-drains/destinations/bigquery.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ export const bigqueryDestination: DrainDestination<
304304
const text = await response.text().catch(() => '')
305305
throw new Error(`BigQuery probe failed (HTTP ${response.status}): ${text}`)
306306
}
307+
/** Drain the success body so undici can return the socket to the keep-alive pool. */
308+
await response.text().catch(() => '')
307309
},
308310

309311
openSession({ config, credentials }) {

apps/sim/lib/data-drains/destinations/datadog.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ async function postWithRetries(input: PostInput): Promise<Response> {
172172
logger.debug('Datadog request failed', { attempt, error: toError(error).message })
173173
}
174174
if (response) {
175-
if (response.ok) return response
175+
if (response.ok) {
176+
/** Drain the success body so undici can return the socket to the keep-alive pool. Headers remain readable after consumption. */
177+
await response.text().catch(() => '')
178+
return response
179+
}
176180
if (!isRetryableStatus(response.status)) {
177181
const text = await response.text().catch(() => '')
178182
throw new Error(`Datadog responded with HTTP ${response.status}: ${text}`)

0 commit comments

Comments
 (0)