Skip to content
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

duplicate writes to stdout on initial write #269

Closed
logicminds opened this issue Feb 16, 2019 · 3 comments
Closed

duplicate writes to stdout on initial write #269

logicminds opened this issue Feb 16, 2019 · 3 comments

Comments

@logicminds
Copy link

Environment details

  • OS: OS X
  • OS version: 10.13
  • node-pty version: 0.8.1

Issue description

I recently switched from the older pty module of which this project was forked from and noticed some differences in terms of how writing to stdout and stdin are handled.

Previously I was using processPty.stdin.write to write data to the console. The cli app (processPty) would read from stdin, process it and then write to stdout. Because the app wrote to stdout the processPty.on('data') event would be triggered.

After switching to node-pty I had to refactor the code and use processPty.write instead. I am hoping that this change runs the exact same code as processPty.stdin.write used to.

However, my observations shows that processPty.write might be sending to stdin and stdout. Additionally, my cli app then writes to stdout as well. So I get double outputs to stdout.

Furthermore, this seems to only occur on the first processPty.write as subsequent writes do not exhibit this double stdout write behavior. Almost as if the initial echo to stdout happens before my cli app has completed initialization/loading (takes about 1500 ms to initialize).

You can view this intended and actual behavior in my apps below:

This problem looks to be the same as #180 and #78

@Tyriar
Copy link
Member

Tyriar commented Feb 21, 2019

Can you share the old/new server code?

@Tyriar
Copy link
Member

Tyriar commented Feb 21, 2019

AFAIK node-pty is behaving correctly by duplicating here, this is what other terminals do as well:

screen shot 2019-02-21 at 2 00 54 pm

I don't know why you're not seeing it with pty.js but I'm interested. term.stdin.write should be the same as term.write:

https://github.com/chjj/pty.js/blob/fe63a412574f45ee6bb6d8fab4a5c102107b5201/lib/pty.js#L331-L337

@Tyriar
Copy link
Member

Tyriar commented Feb 21, 2019

Maybe this is why? chjj/pty.js@ef6aa14

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

No branches or pull requests

2 participants