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

decouple init and start #4

Closed
wants to merge 9 commits into from
Closed

Conversation

szymonkaliski
Copy link
Member

@szymonkaliski szymonkaliski commented May 3, 2024

Currently starting the child process is tied to the Pty initialization, which can lead to a race condition like:

  1. create a Pty which evaluates echo 'hello' -- this returns fd and starts the child process immediately
  2. wait a couple of ms
  3. start reading from the fd -- it is already invalid since the child exited!

This PR decouples creating the Pty/fd from actually starting the child -- the new can start the process at an arbitrary later point in time test shows how that works.

This PR also pins the CI bun version to 1.0.26 which is what the flake.nix is pinned to. I'll follow up with updating bun version in another PR.

@@ -3,13 +3,16 @@

/* auto-generated by NAPI-RS */

export interface Pid {
pid: number
}
export interface Size {
cols: number
rows: number
}
export class Pty {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does napi-rs preserve comments? it would be neat to have a little warning in the docstring telling folks to always start reading from the FD before calling start to avoid surprises.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, this file is auto-generated, not sure if we can inject comments into it

@lhchavez lhchavez mentioned this pull request May 3, 2024
lhchavez added a commit that referenced this pull request May 3, 2024
#4 added a lot of good CI improvements. Let's land them ASAP!

This change takes #4 and only keeps the changes needed to fix CI and
local Linux development.

---------

Co-authored-by: Szymon Kaliski <[email protected]>
@szymonkaliski
Copy link
Member Author

Closing, superseded by #8, #9, #10.

@szymonkaliski szymonkaliski deleted the sk/decouple-init-and-start branch May 6, 2024 09:36
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

Successfully merging this pull request may close these issues.

2 participants