Skip to content

Is there a race condition in child process creation/error listening? #1198

@pushkin-

Description

@pushkin-
  • Node.js Version: 7.9.0
  • OS: Windows 10
  • Scope (install, code, runtime, meta, other?): runtime
  • Module (and version) (if relevant): child_process

Is there a race condition here?

const proc = cp.spawn(...);
proc.on("error", (err) => throw err);

What would happen if the process failed to spawn before we added the error handler? Would we never get the error?

I suppose the solution is to ping the process to test that it's alive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions