Skip to content

Commit 0fa212a

Browse files
committed
fix(data-drains): drain snowflake poll bodies on 202 and retryable status
Mirrors the bigquery/datadog/gcs drains. Long async statements can poll many times against the same connection; without consuming the body undici can't return the socket to the keep-alive pool, so each iteration leaks a connection until GC.
1 parent f8eb36a commit 0fa212a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ async function pollStatement(input: PollInput): Promise<void> {
351351
continue
352352
}
353353
if (response.status === 202) {
354+
/** Drain the body so undici can return the socket to the keep-alive pool between polls. */
355+
await response.text().catch(() => '')
354356
retryAttempt = 0
355357
interval = Math.min(interval * 2, POLL_MAX_INTERVAL_MS)
356358
continue
@@ -367,6 +369,8 @@ async function pollStatement(input: PollInput): Promise<void> {
367369
status: response.status,
368370
delayMs: delay,
369371
})
372+
/** Drain the body so undici can return the socket to the keep-alive pool between retries. */
373+
await response.text().catch(() => '')
370374
await sleepUntilAborted(delay, input.signal)
371375
skipIntervalSleep = true
372376
continue

0 commit comments

Comments
 (0)