-
Notifications
You must be signed in to change notification settings - Fork 3
Description
For each of stdin, stdout, and stderr, the stream will be accessible on the child process object if and only if "pipe" was passed as the relevant stdio
options. For example, if you did var child = spawn(cmd, args, { stdio: ["pipe", someStream, "pipe"]}
, then you would be able to read child.stderr
and write child.stdin
, but child.stdout
would be null.
Currently, there's no handling of this. The types say that all three are always available, and so you can get null
out when you try to access child.stdout
. I'm not sure how best to handle this, but I think a good start would just be throwing an error inside the accessors stdout
, stderr
, stdin
so that at least the cause and fix is obvious. Currently, a null
would leak into your program, which would probably throw an error eventually, but it might be a long way away from the actual problem. Not ideal.
I'm going to implement the above in my PR in a second, but I just wanted to raise this issue in case you have any better ideas.