-
Notifications
You must be signed in to change notification settings - Fork 236
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
Port project to N-API #432
Conversation
@deepak1556 could you check this out when you get a chance? |
Tested on all three platforms 👍 |
|
A crash when an Electron renderer process gets reused. Looks like Node is forcefully stopping all AsyncWorkers during cleanup and an OnOK callback in node-pty crashes:
|
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.
@Eugeny the PR doesn't make the module multi-context aware but rather a refactor from NAN to NAPI.
LGTM for api changes.
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.
I tested this out and it seems to work initially, but when I create a 5th terminal in VS Code it doesn't work, and from that point on I cannot exit VS Code. It happens on both macOS and Windows (I didn't check Linux).
Steps to repro:
- Setup VS Code dev env
-
cd node_modules rmdir node-pty git clone https://github.com/DavidRusso/node-pty cd node-pty git checkout napi yarn
./scripts/code.bat
(or sh)
* | ||
* Ported to N-API by Matthew Denninghoff and David Russo | ||
* Reference: https://github.com/nodejs/node-addon-api | ||
* |
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.
We can add this to the big files ((con|win)?pty.cc
) if you want since this was a lot of effort, but it's a little overkill for the small ones. You'll be in commit history 🙂
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.
Sounds good!
Same on Linux: Eugeny/tabby#3337 |
This may sound disruptive - I think the module should not be moved to the new native API without addressing the underlying bugs it already has (see #85 which reveals serious issues around the blocking semantics). To me it seems more appropriate to rewrite the whole module from scratch with the new API to get rid of those low level issues (and that awkward |
While I strongly agree that #85 is a serious issue, I don't think that it warrants delaying support for upcoming Electron versions once V8 API gets effectively banned. Even though above makes |
@Eugeny I admit that #85 has been around for ys, still the module is basically broken in this regard. A major API shift always opens the door to also get rid of those buried more serious issues, as you have to touch 80% of the code anyway. Note that it just happens to work for 90% of the module user by accident, because they normally use it with a shell and manage to attach a data handler fast enough. Still it shows nondeterministic behavior at these edges. |
Closing since this change has the remaining pretty big issue #432 (review). We do want to move to NAPI and may be force to eventually depending on Electron (if nan support breaks), that will make sharing binaries across platforms much nicer. |
* Port to NAPI The "5th pty bug" in #432 fixed also. * Fix help message in pty.cc * Move NAPI deps to devDependencies in package.json * Apply most of deepak1556's suggestions * Fix winpty * Fix conpty missing CloseHandle * Use unique_ptr to avoid `goto`s * Why macos failed? * fix: ci and minor cleanups * fix build failed on windows --------- Co-authored-by: deepak1556 <[email protected]>
Is there any interest in porting the project from NAN to N-API? If so, here is a working port.