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

Stdio pipe impacts plugin shutdown #9293

Open
Courey opened this issue Apr 23, 2024 · 0 comments
Open

Stdio pipe impacts plugin shutdown #9293

Courey opened this issue Apr 23, 2024 · 0 comments

Comments

@Courey
Copy link

Courey commented Apr 23, 2024

Reproduction

reproduction

repro repo

proposed fix

Branch with desired changes

I was unsure how to test this so I didn't make it a PR (you are welcome to make it a PR should you want to). I am happy to do so if you will tell me where/how to test this change. I am not sure that this is the precise change that should be made though or if there are additional changes that would need to be made along side.

steps to reproduce issue

  • run npm install
  • run npm run dev
  • observe that there is a plugin startup message starting example sandbox plugin
  • press ctl + c to quit the process
  • observe that there is no plugin stopped message
  • go into your node_modules to node_modules/@remix-run/dev/dist/devServer_unstable/index.js
  • change line 139 so that instead of having stdio: "pipe" you have it broken into two lines, one for stdout: "pipe" and one for stdin:"inherit" like so:
let newAppServer = execa__default["default"].command(cmd, {
   stdout: "pipe",
   stdin: "inherit",
   env: {
      NODE_ENV: "development",
      PATH: bin + (process.platform === "win32" ? ";" : ":") + process.env.PATH,
      REMIX_DEV_ORIGIN: options.REMIX_DEV_ORIGIN.href,
      FORCE_COLOR: process.env.NO_COLOR === undefined ? "1" : "0"
   },
   // https://github.com/sindresorhus/execa/issues/433
   windowsHide: false
   })
  • re-run npm run dev
  • again you should see the plugin start message starting example sandbox plugin
  • again press ctl + c to quit the process
  • observe that now you see the plugin stop with stopping example sandbox plugin
  • observe that the main process continues to run until you press ctl + c again.
    I am unsure how to solve for the double ctl + c so I don't know that this is the appropriate solution to my issue, but I can at least improve my issue with this change.

(note: the change in the example is in a different location than the change in the branch, this is because the example updates the already installed module)

System Info

System:
    OS: macOS 13.4
    CPU: (12) arm64 Apple M2 Max
    Memory: 356.70 MB / 96.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
  Browsers:
    Chrome: 124.0.6367.62
    Safari: 16.5
  npmPackages:
    @remix-run/architect: workspace:* => 2.9.0
    @remix-run/changelog-github: ^0.0.5 => 0.0.5
    @remix-run/cloudflare: workspace:* => 2.9.0
    @remix-run/cloudflare-pages: workspace:* => 2.9.0
    @remix-run/css-bundle: workspace:* => 2.9.0
    @remix-run/dev: workspace:* => 2.9.0
    @remix-run/node: workspace:* => 2.9.0
    @remix-run/react: workspace:* => 2.9.0
    @remix-run/testing: workspace:* => 2.9.0
    vite: 5.1.3 => 5.0.0

Used Package Manager

npm

Expected Behavior

I would expect that plugins would gracefully shut down before the main process is killed. In the included repro repo I have a plugin that logs on start and logs on end. When I press ctl + c I would expect the child process running the architect plugins to close gracefully and log stopping example sandbox plugin.

Actual Behavior

The main process is killed without graceful shutdown of plugins. This can have various impacts depending on what you are doing in your plugin. It could cause data loss if the plugin interacts with a database. In our case it leaves a dockerode process running till you kill it in docker desktop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants