consuming spawn UV_EACCES errors #1769
Copy link
Copy link
Closed
Description
- Node.js Version: 11.9.0
- OS: linux
- Scope (install, code, runtime, meta, other?):
- Module (and version) (if relevant):child_process.js
How should one consume UV_EACCES errors raised using spawn?
Assuming code like this:
const { spawn } = require('child_process');
const ls = spawn('ls', ['-lh', '/usr'],{cwd: '/dir/that/has/permissions/set/to666});
//next line throws an error because stdout does not exist due to UV_EACCES error:
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ls has an error event, but how should I access this before ls.stdout throws an error?
Metadata
Metadata
Assignees
Labels
No labels
Activity
gireeshpunathil commentedon Apr 30, 2019
the way I understand
spawnlogic is: treat any errors that occur uptofork / clonesystem call within the parent, and synchronously, while anything after that, handle as anerrorevent on the child process, asynchronously. When checked withstrace, I see theUV_ACCESSis occurring once the child has started execution, so I would expect it to emit an error event, deeming it as a runtime error - I guess that is not happening here. Pinging @nodejs/child_process to see if there is an explanation to this behavior.cjihrig commentedon May 14, 2019
I believe nodejs/node#26852 is tracking this same issue.
gireeshpunathil commentedon Jun 19, 2019
@TrevTheDev - nodejs/node#27696 is merged into node, does it solve your issue?
gireeshpunathil commentedon Jul 15, 2019
answered, closing