"Error: EAGAIN: resource temporarily unavailable, read" when using --standard-json flag
When trying to use the command line with the flag --standard-json, the following error is thrown
solcjs --standard-json Example.json
internal/fs/utils.js:230
throw err;
^
Error: EAGAIN: resource temporarily unavailable, read
at Object.readSync (fs.js:537:3)
at tryReadSync (fs.js:352:20)
at Object.readFileSync (fs.js:389:19)
at Object.<anonymous> (/usr/lib/node_modules/solc/solcjs:37:18)
at Module._compile (internal/modules/cjs/loader.js:1151:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
errno: -11,
syscall: 'read',
code: 'EAGAIN'
}
This looks like access to an imported file is failing. Which filesystem are you using and what is the path your are importing?
This was tested on two different Ubuntu 18 machines, both accesing a typical file. Note that the solc compiler does work. Running solc --standard-json example.json succesfully outputs the result, while solcjs --standard-json example.json (on the same file) ends up in the error shown above.
The same issue appears whether solcjs is installed globally or locally on a project.
Hey, this appears to be related to this git issue: https://github.com/nodejs/node/issues/7439 (Edit: okay, old node version, but an issue with the same API. I'm seeing this on OSX as well). See https://github.com/ethereum/solc-js/blob/e38dbe732ad596eb041b79e5cdd7f6196126708f/solcjs#L60. I'd be happy to work on a fix if I can get an agreement on the approach.
@JackVCurtis What's your suggested approach?
The "right" way to read from stdin in node.js seems to read data in chunks using process.stdin.read() so the solution would be to create a small helper for doing that until it gets the whole file. There's probably no point in doing anything asynchronous here since the compiler needs the whole input in one go anyway.