-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
feat(std/node/process)-stdin-stdout-stderr #7184
feat(std/node/process)-stdin-stdout-stderr #7184
Conversation
@ry Id love your thoughts on the preferred way to add these in, or if what i have falls in line with current codebase practices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good start
Heavy WIP branch, still needs lots of testing |
@ry This is ready for a review round when you have time! |
Weird. Tests work locally for me. investigating
|
Could be that the Perhaps try this way instead:
Tests for |
Actually, that won't work, as it would need to be instantiated. |
Maybe something like this using Proxies
|
@JayHelton Any idea why this is failing? Seems to be the related to the improvements you're making. |
@ry I know whats causing the failure, but not quite sure on the cause of the cause. The assertion on the From the ubuntu ci logs with a console.log I added
When i run
|
Im going to try the above suggestion to Proxy and see if that will achieve more consistent results |
@ry before i dive deeper into debugging, i wanted to ask you this.
|
The bug is still around on the ubuntu image and I havent been able to prove what the issue is. Stdin, Stdout, and Stderr are not recognized as TTYs in the Ubuntu CI, but they are with everything ive tried locally (OSX). Its not just the node/process std impls, The rid does not change either, as stdin, out, and err are instantiated with rids 0,1, and 2 (consistent with the file descriptors) In the rust operation, there is a specific block at line 242 in tty.rs that is for unix, and then right above that is windows. I dont see anything special for linux, so im assuming that on linux is either matching on an error I dont have a ubuntu box to test this unfortunately. Any suggestions or ideas? |
@JayHelton It's probably because the stdio aren't TTYs in the CI scenario. In order to properly test these values, we'd need to setup a PTY... it's not immediately clear to me how we would do that - since Deno doesn't yet have bindings for that... |
This makes total sense why im seeing what im seeing. In the mean time, would you accept a TODO with these isTTY assertions comment out, referencing the above? |
Additionally, I can start looking into how we can start supporting PTY, though there is a big bag of grey area that i would have to color in |
std/node/process_test.ts
Outdated
name: "process.stdin", | ||
fn() { | ||
assertEquals(typeof process.stdin.rid, "number"); | ||
assertEquals(process.stdin.rid, Deno.stdin.rid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Node there isn't a process.stdin.rid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay! I’ll get peep everything on node.process and replicate it more explicitly instead of spreading denos stdio.
Yes leaving a TODO is fine |
std/node/process.ts
Outdated
@@ -38,6 +38,30 @@ export const process = { | |||
platform, | |||
version, | |||
versions, | |||
get stderr() { | |||
return { | |||
...Deno.stderr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be explicit about the properties you want to expose here, this is very brittle and can break anytime additions or changes are made to Deno.stderr (Hasn't happened yet but theoretically it can happen).
std/node/process.ts
Outdated
}, | ||
get stdin() { | ||
return { | ||
...Deno.stdin, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
std/node/process.ts
Outdated
}, | ||
get stdout() { | ||
return { | ||
...Deno.stdout, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
LMK if this is a bit more inline with what would be safe! What is the denomatic way to port over a method that does not return a promise? The stdout and err both have a write method i was going to add on the objects, but the Deno methods return a promise. It doesnt seem very backwards compatible if they both return a promise |
Just to make it explicit, these Node.js methods are needed for any substantial compat.
|
Hey all, ive spent time researching the Node implementations of the methods mentioned in previous comments on this PR. I dont know the best way to implement these methods in a way that respects nodes callback based architecture. I am not confident Ill be able to find and implement those solutions without a little pairing and more time. I would recommend reviewing as is, fixing for the specific use case in the original ticket, and then we can add more support as needed. Additionally, if anyone wants to grab this branch and work on it as well, definitely open to that! I am looking at a busy next few weeks and would prefer if this did not get too stale. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thank you - sorry for the delay!
Description
Adding more backwards compatibility stderr, stdin, stdout for the node/process module'
References