Skip to content

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

Description

@MartinKolarik

Please make sure you have searched for information in the following guides.

A screenshot that you have tested with "Try this API".

N/A, the bug is in the client code.

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://gist.github.com/MartinKolarik/04bcb1ac4209d3afee62a31667f666d7

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

  1. Create a large local file.
  2. Start bucket.upload.
  3. Force an early failure (e.g., upload to a bucket without write permissions).
  4. Delete the local file while the process is alive.
  5. Check /proc/<pid>/fd and df/du.

A clear and concise description of what the bug is, and what you expected to happen.

The file descriptor open in bucket.upload remains allocated until the process exists. This causes a small memory leak and prevents the local file from being fully deleted. The relevant code is: https://github.com/googleapis/nodejs-storage/blob/c7004daae0b506eeefc5f4f241d9e3df3589b0e8/src/bucket.ts#L4364-L4379

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

The file descriptor should always be closed when the function finishes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storageIssues related to the Cloud Storage API.library: storageIssues transferred from another repository

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions