Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writeSync can throw EAGAIN, but csslint doesn't handle it #765

Open
cpitclaudel opened this issue Mar 31, 2020 · 0 comments
Open

writeSync can throw EAGAIN, but csslint doesn't handle it #765

cpitclaudel opened this issue Mar 31, 2020 · 0 comments

Comments

@cpitclaudel
Copy link

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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant