ansi-html-stream icon indicating copy to clipboard operation
ansi-html-stream copied to clipboard

Fix run-time usage of require()

Open Jimbly opened this issue 10 years ago • 0 comments

This is generally bad because it does synchronous file I/O, which means if your server is under heavy disk load when this function is first called, the entire node process will stop serving requests until it can get disk access. This is specifically bad for me because it messes with various hot-reloading process managers (ones which leave your process running while it does an update underneath it, and then restarts your cluster workers), since during an npm update "./colors.js" might not exist, and if this function is first called during this time, then this module does not work.

Since we use this module (as part of https://github.com/Jimbly/node-pipe-to-browser) for streaming our log files from our server, it turns out that "high disk load" and "server is being updated" are states that very often overlap "immediate need to see the log files" =).

Jimbly avatar May 12 '15 16:05 Jimbly