Skip to content

bugfix: prevent ObjectUploader from closing user-provided resource handles#3296

Merged
stobrien89 merged 1 commit into
aws:masterfrom
stobrien89:bugfix-objectuploader-stream-handling
Jun 2, 2026
Merged

bugfix: prevent ObjectUploader from closing user-provided resource handles#3296
stobrien89 merged 1 commit into
aws:masterfrom
stobrien89:bugfix-objectuploader-stream-handling

Conversation

@stobrien89

Copy link
Copy Markdown
Member

Issue #, if available:
closes #3295

Description of changes:
ObjectUploader wraps user-provided PHP resources in a Psr7\Stream via Utils::streamFor(). Stream::__destruct() calls fclose() on the underlying resource. Before #3290, a cyclic reference in the retry middleware kept the Stream alive indefinitely, so __destruct() never fired during the request lifecycle. After #3290 fixed the cycle, the Stream destructs promptly and closes the user's handle before upload() returns.

This change wraps user-provided resources with FnStream::decorate(), overriding close() to call detach() instead of fclose(). The SDK no longer takes ownership of resources it did not open.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@stobrien89 stobrien89 force-pushed the bugfix-objectuploader-stream-handling branch from 7cf73ac to 61c1a09 Compare June 2, 2026 17:21
@stobrien89 stobrien89 merged commit 5be27d1 into aws:master Jun 2, 2026
17 checks passed
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.

Breaking change in 3.383.1: file handles are now closed by S3Client->upload()

2 participants