Skip to content

fix(fs-aws): forward body stream errors in readStream - #1743

Open
stella-mcgann wants to merge 1 commit into
blacha:masterfrom
stella-mcgann:fix/fs-aws-readstream-errors
Open

stella-mcgann wants to merge 1 commit into
blacha:masterfrom
stella-mcgann:fix/fs-aws-readstream-errors

Conversation

@stella-mcgann

Copy link
Copy Markdown

Motivation

readStream() pipes the S3 response body into a PassThrough with .pipe(), which doesn't forward errors. If the connection drops mid-download (e.g. ECONNRESET), the error is emitted on the AWS SDK's ChecksumStream with no listener, so Node throws an unhandled 'error' event and the process exits. Error handlers on the returned stream never see it.

When the response has no checksum header, the same drop makes the returned stream hang instead: it never ends or errors.

We hit this in argo-tasks stac-validate, which crashed partway through checksumming a large collection.

Modification

Listen for error on the response body and destroy the returned stream with an FsError, using the same wrapping as the existing .catch().

Verification

  • Existing unit tests passed
  • Reproduced locally with a fake S3 endpoint that drops the connection mid-download: before the fix the process crashes with an unhandled ECONNRESET on ChecksumStream; after, the error is emitted on the returned stream as an FsError

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant