Skip to content

child_process.spawn() uncatchable error #3523

@doivosevic

Description

@doivosevic

After calling

try {
    child_process.spawn('kill ' + pid + ';screen -d -m -L node ' + serverjsLocation);
}
catch (e) {
    filelog(e);
}

I get

events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: spawn kill 11088;screen -d -m -L node /home/git/Gitorade/server.js ENOENT
    at exports._errnoException (util.js:874:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at doNTCallback2 (node.js:439:9)
    at process._tickCallback (node.js:353:17)

Node version is 4.2.1
I added try block after I started getting this error so that I might debug it.
Is this the proper way to catch this exception?
The docs (https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) do not mention callback although this is an async function. How so? I went throught nodejs internal code and while I did not get too into it I got a feeling that the function is expected to have a callback.

How do I catch this error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions