Fails with non-existing file #8

naholyr opened this Issue Oct 30, 2011 · 2 comments


None yet

1 participant

naholyr commented Oct 30, 2011

In a unpiped context, creating an instance with a non-existing path fails:

var filed = require("filed")
f = filed("./unexisting-file")


{ writable: true,
  readable: true,
  buffers: [],
  path: './toto.txt',
  index: 'index.html',
  _events: { pipe: [Function] },
  buffering: true,
  mimetype: 'application/octet-stream' }

but also throws

        throw arguments[1]; // Unhandled 'error' event
Error: ENOENT, No such file or directory './toto.txt'

no time to call write() or end(), it has already failed

I suppose it's linked to the fact that there is no pipe around, because this works:


Anyway, the very first example of the README fails because of this issue :x

naholyr commented Oct 30, 2011

I found a way to fix it, at line 46:

if (err && !self.dest && !self.src) return self.emit('error', err)

we should add before this line:

if (err && err.code === 'ENOENT' && !self.dest && !self.src) self.src = self.path

This way the call to finish() would go until line 141 and create a WriteStream.

naholyr commented Oct 30, 2011

Closed by PR

@naholyr naholyr closed this Oct 30, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment