Skip to content

The standard streams problem #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hdgarrood opened this issue Dec 11, 2015 · 2 comments
Closed

The standard streams problem #4

hdgarrood opened this issue Dec 11, 2015 · 2 comments

Comments

@hdgarrood
Copy link

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.

@joneshf
Copy link
Owner

joneshf commented Dec 27, 2015

Maybe that's why I separated the effects out and never go around to making smart constructors? Sorry, I can't really remember. I think it'd probably be better to not have to deal with nulls creeping in if we can help it.

@hdgarrood
Copy link
Author

Yeah, that could well be it.

Currently it just throws an error if the stream turns out to be null. I'm struggling to come up with a safer API right now. I think I'll just open an issue on the purescript-node repository and maybe come back to it later. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants