fs: fix immediate WriteStream#end()
authorBen Noordhuis <info@bnoordhuis.nl>
Mon, 11 Feb 2013 13:01:18 +0000 (14:01 +0100)
committerBen Noordhuis <info@bnoordhuis.nl>
Mon, 11 Feb 2013 20:15:13 +0000 (21:15 +0100)
commitc7b84a1d01fa4fd6ccff1ceb917a5aaf59694244
tree720d51cbc760be111e7bb22596460f690be55b2e
parented3d553d826963837dee5db9cf6cc88b2d5c62cc
fs: fix immediate WriteStream#end()

Fix an exception that was raised when the WriteStream was closed
immediately after creating it:

  TypeError: Cannot read property 'fd' of undefined
      at WriteStream.close (fs.js:1537:18)
      <snip>

Avoid the TypeError and make sure the file descriptor is closed.

Fixes #4745.
lib/fs.js
test/simple/test-fs-write-stream-end.js