docusaurus
docusaurus copied to clipboard
Dev server process not terminated by SIGINT when loader is stuck
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the
npm run clearoryarn clearcommand. - [X] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand 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 https://github.com/facebookincubator/infima/pull/219
Reproducible demo
No response
Steps to reproduce
- Init
- Change the options:
docs: {
sidebarPath: require.resolve('./sidebars.js'),
// A hopeless infinite loop
remarkPlugins: [() => { while (true); }],
},
yarn start- Oh no, page stuck. SIGINT (Ctrl + C) to the rescue
yarn startagain[WARNING] Something is already running on port 3000. Probably:- What? Run
lsof -i tcp:3000=> The dev server process is indeed still running - 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
- [X] I'd be willing to fix this bug myself.
yes noticed that too
Note devServer.stop() returns a promise, maybe we just have a missing await?
~~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
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 :/
@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?
🤷♂️ I don't know 😅 if it can work without any extra dependency I guess it's better
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).
It also happens to me occasionally (yarn1, macos), but I have never been able to find the cause 😅
me too 👍