Skip to content

Commit 635907d

Browse files
waleedlatif1claude
andcommitted
fix(data-drains): lazy-init S3 endpoint DNS check
Creating the check eagerly in openSession could yield an unhandled rejection if the source produced no chunks (deliver never ran). Defer construction to the first deliver call so the promise is always awaited. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 1ece3d4 commit 635907d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • apps/sim/lib/data-drains/destinations

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,12 @@ export const s3Destination: DrainDestination<S3DestinationConfig, S3DestinationC
188188
// pay the lookup once. The SDK creates its own connections, so we can't
189189
// pin the IP — but doing the check before any S3 call still rejects
190190
// hostnames that resolve to internal targets at the start of the run.
191-
const endpointCheck = assertEndpointIsPublic(config.endpoint)
191+
// Lazy-init avoids an unhandled rejection if the source yields no chunks
192+
// and `deliver` never runs (e.g., a drain with nothing new to export).
193+
let endpointCheck: Promise<void> | null = null
192194
return {
193195
async deliver({ body, contentType, metadata, signal }) {
196+
if (endpointCheck === null) endpointCheck = assertEndpointIsPublic(config.endpoint)
194197
await endpointCheck
195198
const key = buildKey(config, metadata)
196199
await withS3ErrorContext('put-object', () =>

0 commit comments

Comments
 (0)