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

Dev server process not terminated by SIGINT when loader is stuck #6958

Open
5 of 7 tasks
Josh-Cena opened this issue Mar 22, 2022 · 8 comments
Open
5 of 7 tasks

Dev server process not terminated by SIGINT when loader is stuck #6958

Josh-Cena opened this issue Mar 22, 2022 · 8 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Mar 22, 2022

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

If the loader has an infinite loop or any other bug that causes it to get stuck, the dev server keeps running even when SIGINT is sent.

Discovered while working on facebookincubator/infima#219

Reproducible demo

No response

Steps to reproduce

  1. Init
  2. Change the options:
        docs: {
          sidebarPath: require.resolve('./sidebars.js'),
          // A hopeless infinite loop
          remarkPlugins: [() => { while (true); }],
        },
  1. yarn start
  2. Oh no, page stuck. SIGINT (Ctrl + C) to the rescue
  3. yarn start again
  4. [WARNING] Something is already running on port 3000. Probably:
  5. What? Run lsof -i tcp:3000 => The dev server process is indeed still running
  6. Use the force: kill -9 47874

Expected behavior

SIGINT should be able to stop the dev server

Actual behavior

It keeps running in the background and listening on port 3000. Probably the compile process is never hung properly...

Self-service

  • I'd be willing to fix this bug myself.
@Josh-Cena Josh-Cena added the bug An error in the Docusaurus core causing instability or issues with its execution label Mar 22, 2022
@Josh-Cena Josh-Cena changed the title Dev server process not terminable when loader is stuck Dev server process not terminated by SIGINT when loader is stuck Mar 22, 2022
@slorber
Copy link
Collaborator

slorber commented Mar 23, 2022

yes noticed that too

Note devServer.stop() returns a promise, maybe we just have a missing await?

@Josh-Cena
Copy link
Collaborator Author

Josh-Cena commented Mar 23, 2022

Oh, I think that's it! No, changed it to devServer.stop().then(() => process.exit()); and the dev server is still stuck in the background

@slorber
Copy link
Collaborator

slorber commented Mar 23, 2022

weird, maybe the compiler should also be closed?

I've also noticed that sometimes yarn build + sigint wouldn't stop the process when building multiple locales, probably a similar issue :/

@Josh-Cena
Copy link
Collaborator Author

@slorber process.on must be handled synchronously. I tried and found out that simply deleting the SIGINT handler would work (using WDS' default signal handler). Do you think we should bring in something like node-graceful or simply relying what's the default?

@slorber
Copy link
Collaborator

slorber commented Mar 25, 2022

🤷‍♂️ I don't know 😅 if it can work without any extra dependency I guess it's better

@BanDroid
Copy link

BanDroid commented Apr 8, 2024

hey, i got this problem, not sure why but single CTRL + C does not stop the process, i had to CTRL + C twice, but somehow the process still running in background (i got the same problem with port already in use when i start the server again).

Note: i use pnpm to run it, the project itself i just started to make it from template and nothing are changed, so i dont think the bug was from my end. my system is ubuntu 20 with Bodhi Linux distro 64-bit (arm64).

@slorber
Copy link
Collaborator

slorber commented Apr 11, 2024

It also happens to me occasionally (yarn1, macos), but I have never been able to find the cause 😅

@KnowledgeGarden
Copy link

me too 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
Development

No branches or pull requests

4 participants