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

Closed
bnoordhuis opened this Issue Dec 7, 2012 · 1 comment

Projects

None yet

2 participants

@bnoordhuis
Member

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
isaacs commented Dec 7, 2012

It should absolutely close the fd on error.

@bnoordhuis bnoordhuis added a commit to bnoordhuis/node that referenced this issue Dec 12, 2012
@bnoordhuis bnoordhuis fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.

Fixes #4387.
06ed12a
@bnoordhuis bnoordhuis added a commit to bnoordhuis/node that referenced this issue Dec 12, 2012
@bnoordhuis bnoordhuis fs: fix WriteStream fd leak
Close the file descriptor when a write operation fails.

Fixes #4387.
ce25575
@bnoordhuis bnoordhuis added a commit that closed this issue Dec 12, 2012
@bnoordhuis bnoordhuis fs: fix ReadStream fd leak
Close the file descriptor when a read operation fails.

Fixes #4387.
6e97b2c
@bnoordhuis bnoordhuis added a commit that referenced this issue Dec 12, 2012
@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