Skip to content

fix(storage): destroy local read stream on upload write failure to prevent resource leaks#8752

Open
thiyaguk09 wants to merge 6 commits into
googleapis:mainfrom
thiyaguk09:fix/7325-upload-fd-leak
Open

fix(storage): destroy local read stream on upload write failure to prevent resource leaks#8752
thiyaguk09 wants to merge 6 commits into
googleapis:mainfrom
thiyaguk09:fix/7325-upload-fd-leak

Conversation

@thiyaguk09

@thiyaguk09 thiyaguk09 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #7325

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ensures that the local readStream is properly destroyed if errors occur during the upload or piping process, and adds a corresponding unit test to verify this behavior. The review feedback highlights a potential resource leak if createWriteStream or progress listener attachment throws an error synchronously before the readStream is piped, and suggests instantiating the readStream after the writable stream is set up.

Comment thread handwritten/storage/src/bucket.ts Outdated
@thiyaguk09 thiyaguk09 marked this pull request as ready for review June 25, 2026 12:37
@thiyaguk09 thiyaguk09 requested a review from a team as a code owner June 25, 2026 12:37
Comment thread handwritten/storage/src/bucket.ts Outdated
@thiyaguk09 thiyaguk09 requested a review from Dhriti07 June 26, 2026 06:48
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.

File descriptor not closed on remote bucket.upload() errors

2 participants