-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Dev server v2 kills arc sandbox
ungracefully, not giving sandbox plugins a chance to clean up
#6871
Comments
I tried to remove all Remix code for killing the app server process, but my system was still killing the app server when The only way the app server process stayed alive is when I set |
@pcattori, I think that part of the problem is that arc sandbox itself doesn't handle signals. I opened the PR architect/sandbox#729 to try to address that. Would you please see if your changes on the Remix side work when combined with that PR? |
I did some testing on this issue as I could see it as well. I was able to change my docker to use an entrypoint. In my entrypoint I created a signal trap. I was able to trap all signals. This told me that sending signals from outside of docker into docker was working. I then ensured that I was using exec in the entrypoint so that the second process after docker-init would be I went digging and I have found this issue and this PR that I believe may be the cause (or a partial cause) of this issue. I have updated my npm version to be the most recent version (10.3.0) and I was able to see it close the process in under a second when I use control + c, so I believe this should fix it. |
@pcattori could you please ensure your npm version is 10.3.0 and try your experiment again? I am hopeful this is your issue. |
I spoke to @lpsinger and this did not impact the issue he was having. I want to be more specific about what I was seeing and what was fixed with the npm version change. In the buggy version, you send a sigint/term to docker (depending on what you have configured and if you use compose). NPM was catching these but doing nothing with them. So as you tried to close the npm run process, it would hang for 10 seconds till it hit the Docker timeout and docker sends a sigkill. So I was unable to get to the remix layer at all because the signal was being trapped before that. All the npm version change does is make it so that npm isn't just trapping and keeping the signal. So now the signals get passed along. It does not however show any additional logging or proof of graceful shutdown in remix. |
I can reliably "gracefully" terminate the child process now, but I have done terrible things to get there. I am hoping though that this at least helps point in the right direction and maybe one of you will advise further. in in the devServer_unstable/index file, if I replace
and then in to the sandbox/src/cli/index file in architect's sandbox I ALSO add this:
It will work as expected, but not how I would have thought it would. I added an exit event for the child process so that basically when it exits I then can exit the main process. I did this because handling asynchronous shutdown actions was a beast and this way I'm listening on the main process for the child process to reach exit status which then triggers the exit of the main process. Like I said, super duper ugly, but maybe illuminating? a maybe odd thing: |
@Courey Thanks for diving deep on this! 🙏 We've been heads down on getting Vite stuff stabilized. We're going to need to clean up some of the CLI code soon anyway, so will try to include some/all of this there. In the meantime, would love any arc experts to help me figure out how best to interop with Vite dev server since that's what we're moving to anyway. I think we can use |
I created this issue with Arc because I was able to isolate the process and send it signals manually and did not get the expected response from arc sandbox, so I thought they might be able to tell me more about that and that might point me in the right direction. That was a red herring. They believe the issue lies with execa and how it handles children of children. They seem extremely helpful and friendly, and I know in your comment you said:
I was hoping to introduce y'all to each other because it sounds like it could be a useful pairing. |
What version of Remix are you using?
1.18.1
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
When you are using dev_v2 mode in an Architect app, when you interrupt
npm run dev
with ^C, it kills all subprocesses with extreme prejudice and does not permit Architect plugins to clean up.To reproduce:
start
method (which would normally start a sidecar process --- such as an OpenSearch server) and astop
method (which would normally stop the sidecar process and delete any temporary directories). For example:plugin-sandbox.js
app.arc
npm run dev
. Wait until it's up and running.Expected Behavior
The dev server should come down cleanly and you should see both of the log messages from the Architect sandbox plugin, both
starting example sandbox plugin
andstopping example sandbox plugin
. Here's the good output withdev_v2: false
set. For a reproducer, see https://github.com/lpsinger/remix-bug-report-arc-sandbox-killed-ungracefully/tree/dev_v1.Actual Behavior
Here's the bad output. You see
starting example sandbox plugin
, but you never seestopping example sandbox plugin
. For a reproducer, see https://github.com/lpsinger/remix-bug-report-arc-sandbox-killed-ungracefully/tree/dev_v2.The text was updated successfully, but these errors were encountered: