joyent/node — Issue #1883: v0.5.9 fails to return EISDIR error on fs.read() of a directory
Author: tshinnic
Created: 2011-10-13 21:57:43+00:00
State: open

Noticed this while using fs.createReadStream() and 'bad' filename that was actually a subdirectory.
(test 0.5.x with *bad* data too!)

Tracked down to difference in fs.read() error returns:

[Tom@TLSF15A temp]$ node -v
>> v0.4.12
> [Tom@TLSF15A temp]$ node
> var fs = require('fs')
> var z = fs.openSync('subdir','r')
> var s = fs.readSync(z,16,null,'utf8')
>> Error: EISDIR, Is a directory
at Object.readSync (fs.js:264:19)

[Tom@TLSF15A temp]$ ../node5 -v
>> v0.5.9
[Tom@TLSF15A temp]$ ../node5
> var fs = require('fs')
> var z = fs.openSync('subdir','r')
> var s = fs.readSync(z,16,null,'utf8')
>> Error: UNKNOWN, Unknown error
at Object.readSync (fs.js:265:19)

The cited line in fs.js is

var r = binding.read(fd, buffer, offset, length, position);

Now I'll go check against latest master...