microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.42k stars 233 forks source link

Proposal: Rewrite of native API using rust and N-API #507

Open daniel-brenot opened 2 years ago

daniel-brenot commented 2 years ago

Issue description

I am looking into rewriting the existing implementation of this native library in rust with N-API. I am working on a branch currently where I will publish the changes I am proposing, and I would love feedback on it once I publish the branch as WIP.

Reasons for the rewrite

There are multiple issues regarding cross platform support and Node version that would all be resolved in a rewrite in rust. It would also make solving issues such as the blocking semantics mentioned in #85 much easier.

How does the community feel about this?

If I do write this and make sure there are no errors, will this be used?

corwin-of-amber commented 1 year ago

https://github.com/daniel-brenot/node-pty/blob/rust-port/native/src/win/conpty.rs

Well yeah that was the one I was looking at (the permalink might look weird) and the file in this link you just sent also has the same problem, is seems?

daniel-brenot commented 1 year ago

It seems i have this fixed on my local windows but never pushed the change :facepalm: . I'll push the update shortly, I have a meeting to get to but i may have time to push the update

corwin-of-amber commented 1 year ago

Np! I was suspecting smt like that might have happened. I will check back :)

daniel-brenot commented 1 year ago

Just pushed an update i think should help.

dshook commented 2 months ago

Curious if this is still being worked on

daniel-brenot commented 1 month ago

Curious if this is still being worked on

Yep. I've reached pretty much the end of the road on this sadly as the rewrite doesn't work quite correctly on windows, but i've been informed it works great on linux.

If anyone is interested in helping on the windows version it is appreciated. A lot of work went into my fork and it would make upstream development much easier i'm sure

dshook commented 3 weeks ago

What are the known issues with the windows version? Is there test coverage for all of them?

I'm also curious if you noticed any performance differences spawning the pty's between the original and your branch. It would def be nice to speed up the spawn speed on windows

daniel-brenot commented 3 weeks ago

What are the known issues with the windows version? Is there test coverage for all of them?

I'm also curious if you noticed any performance differences spawning the pty's between the original and your branch. It would def be nice to speed up the spawn speed on windows

I can't imagine what i've done has sped up the spawn speed. It uses more or less the same mechanism as the c++ version and at the moment it doesn't even work!

If I remember correctly, it just hangs when trying to create a terminal session at one point. That or it fails to create a pipe needed for the terminal, i'm unsure. It's been a while since i've worked on this, but i've recently gained a need to finish this so I will most likely be working on it again. Since last time i worked on it chatgpt has been invented, so it may be able to provide insight to the issue.

Yes, there are unit tests for the windows version. This is how I verify that it is not working correctly.

daniel-brenot commented 2 weeks ago

I have come back to the project on windows and it seems that while it does work to create a process, it doesn't work at being connected and calling the necessary callbacks. I'll work to debug why this week as i'd like to have this finally done