writeSync can throw EAGAIN, but csslint doesn't handle it
cpitclaudel opened this issue · 0 comments
Hi there,
I'm a maintainer of Flycheck, a linter UI for Emacs. I'm forwarding a bug report that we think is due to csslint. The report is at flycheck/flycheck#1481. In brief, Emacs starts css lint as a subprocess connected to a pipe. csslint uses writeSync
to write its errors out, and in files with many errors this generates more than 64kB (the size of the pipe) of output. At that point node raises an EAGAIN signal, which csslint doesn't catch:
return binding.writeString(fd, buffer, offset, length, position);
^
Error: EAGAIN: resource temporarily unavailable, write
at Object.fs.writeSync (fs.js:741:18)
at Object.print (/home/me/.config/yarn/global/node_modules/csslint/dist/cli.js:421:12)
at processFiles (/home/me/.config/yarn/global/node_modules/csslint/dist/cli.js:272:25)
at cli (/home/me/.config/yarn/global/node_modules/csslint/dist/cli.js:401:14)
at Object.<anonymous> (/home/me/.config/yarn/global/node_modules/csslint/dist/cli.js:417:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
We've had the same issue in the past with other linters, though with stdin instead of stdout or stderr. We think it's an issue in nodejs (see nodejs/node#4697), due to the fact that stdin and stdout are synchronous on Windows. In any case, when trying to write a large amount of output to stdout on Windows (more than the pipe buffer's size), writeSync can throw EAGAIN, and csslint doesn't catch this error.
Other projects have had the same issue and fixed it in various ways, e.g. eslint (eslint/eslint#12212, eslint/eslint#12230) and mocha (JetBrains/mocha-intellij#2, JetBrains/mocha-intellij@fe9aee6). The fix is likely to not use fs.writeSync
.
Take all this with a grain of salt, because I personally don't use Windows, nor nodejs :) But I do use csslint, and it works great for me ;)