Tuesday, 6 November 2018

fs.WriteStream: Way to detect if underlying file is deleted or otherwise unwritable?

I am opening a file when my server starts by calling fs.createWriteStream in append mode, and I am appending to this stream when I receive a request by calling write on it. You can think of it as a log.If, while the server is running, I delete the file, or say change its permissions so it's no longer writable, no error is thrown. If I delete the file, it fails silently and nothing happens. If I change the permissions so it's no longer writable, the file still gets written to.Is there any way to detect these conditions?

Submitted November 06, 2018 at 05:47PM by thinksInCode

No comments:

Post a Comment