Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fs: streams don't auto-close fd on error #4387

Closed
bnoordhuis opened this Issue · 1 comment

2 participants

@bnoordhuis

fs.ReadStream and fs.WriteStream emit an 'error' event when the read/write operation fails (because of ENOSPC/EIO/etc.) but they don't close the file descriptor. It requires the user to call stream.destroy() explicitly, otherwise the file descriptor is leaked.

I vaguely recall discussing this sometime ago but I forgot what exactly the motivation was (if any). If it's to restart the operation in case of transient errors, I don't think the current implementation is appropriate - it sets the readable and writable properties to false on error.

@isaacs
Owner

It should absolutely close the fd on error.

@bnoordhuis bnoordhuis referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@bnoordhuis bnoordhuis referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@bnoordhuis bnoordhuis referenced this issue from a commit in bnoordhuis/node
@bnoordhuis bnoordhuis fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.

Fixes #4387.
06ed12a
@bnoordhuis bnoordhuis referenced this issue from a commit in bnoordhuis/node
@bnoordhuis bnoordhuis fs: fix WriteStream fd leak
Close the file descriptor when a write operation fails.

Fixes #4387.
ce25575
@bnoordhuis bnoordhuis closed this issue from a commit
@bnoordhuis bnoordhuis fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.

Fixes #4387.
6e97b2c
@bnoordhuis bnoordhuis referenced this issue from a commit
@bnoordhuis bnoordhuis fs: fix WriteStream fd leak
Close the file descriptor when a write operation fails.

Fixes #4387.
d65832c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.