-
Notifications
You must be signed in to change notification settings - Fork 93
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
fixed issue #559 #592
base: main
Are you sure you want to change the base?
fixed issue #559 #592
Conversation
Shamun Khatri seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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 have a feeling that this doesn't always work.
For example, if you let the ./dev.sh script run till completion (or long enough), and then press X, it doesn't quit successfully.
I noticed you replaced ink
's exit
call with process.exit
, which is fine, but the dependencies remain unchanged.
I think I'd have kept both the process.exit
and exit
calls in there.
Additionally...
There's a lot of whitespace changes which I'm not sure are intentional.
Yes, whitespaces are not intentional I have tried many other things that's why they are there. But I got confused about what will not work. You said in a long-running process that might now work why? Also, what does it mean that dependencies remain unchanged? |
One thing I forgot about I have tried keeping both And I have also tried keeping the app(process) running for 5 minutes and then tried X with only |
I wasn't able to reliably reproduce that issue in the past. But yeah, I think call And do remove any unintended code/whitespace changes. I think that'll be it for this PR. |
I hovered around inks codebase and found the reason exit() isn't working is some processes are still active. So the exit() by useApp isn't detaching the terminal. So this solution introduced here might be a hacky way to do things, but it doesn't break anything. Just we can do a check that after calling exit(), if the process is still not killed, then call the process.exit(0) (to keep in mind this isn't forced as code 0 is to safely kill the process). This will ensure that no process is running after the process is unmounted. Else failure to do so might result in terminal being unmounted, but some services still running in the bg. |
Interesting. Yeah I can see how that happens. |
After exit() call in useEffect(), can do:
|
@thesujai I have tried your solution and it is working fine. But why some process is still running there after running Ikn's And are you raising a PR for this, cause you did better job. Or should I raise a PR? |
Try running git blame on this file and see what introduced this bug(Maybe it worked before, not sure)
No, and feel free to update this branch. Good job! |
@jayantbh @thesujai, I have made changes as per the discussion. I have tried to go a little deep-down on this and find that I took reference from here https://nodejs.org/api/child_process.html#subprocesskillsignal So I think the solution we discussed to use both the exits is fine because I think we are using docker and in the end, it is turning off successfully. |
cli/source/app.tsx
Outdated
if(processRef.current) { | ||
process.exit(0); | ||
} |
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.
Why the processRef
check here?
Also, this doesn't look formatted right.
@jayantbh As suggested in this comment I think it would be better to check for any process before calling |
I understand the intent, but given that you didn't really do anything with processRef itself, and that A check for Right now if |
Btw, you could join our OSS Community on Slack for quick back and forth and discussions. |
Ok, I will just kill that and remove unnecessary checks.I have joined the community on slack thanks for sharing. |
I made changes. Please have a look. |
@shamun-khatri, please use better commit names to better reflect the changes within. I wrote about this a while ago. |
a6726ac
to
18a41db
Compare
-This fixed issue middlewarehq#559 -Additionally added after in useEffect when Appstate set to Terminated
18a41db
to
2fbcc89
Compare
@jayantbh I have renamed the commit. I tried my best to write that but if you thing I am still missing anything then do let me know. Also, could you assign me before merging? If it's not counting in Hacktoberfest |
Linked Issue(s)
Closes #559
Proposed changes (including videos or screenshots)
I have used process.exit() in one place (useEffect hook where it checks if AppState === TERMINATED) instead of exit() that is not working. I have tried to solve this issue by debugging and trying other methods but noting works but this.
Here is a screenshot of working terminal detach.
Further comments
I hope this will get merged. But if you think I could do better then tell me I will change things along.