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

Intermittently Gatsby doesn't cleanly exit and the process refuses to be killed #26214

Closed
doingandlearning opened this issue Aug 4, 2020 · 3 comments · Fixed by #26360
Closed
Assignees
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@doingandlearning
Copy link

Description

About once a day, when I restart my Gatsby server it tells me that there is an instance of the project already running. It won't allow me to start another instance on a different port because it is already running.

However, I have no interactive process open. I closed all terminals and reopened but the process is still running.

When I check to see what is listening on the port with lsof -n -i4TCP:8000 | grep LISTEN, I get a node PID. But the process won't be killed either with kill PID or sudo kill PID.

The only fix I've found is to restart the machine.

Steps to reproduce

This is an intermittent problem and I haven't been able to find a clear reproducible case. I'm keeping notes and will hopefully be able to update this issue when I have a clear use case. Part of this issue is to see if there is a shared problem here and other wisdom I can learn from.

Expected result

  • to be able to kill the gatsby process
  • for Ctrl-C or stopping terminal executions of gatsby develop to always cleanly kill the process

Actual result

Process doesn't properly end when exiting terminal.

https://share.getcloudapp.com/P8ubp6z6

Environment

System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.2/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 84.0.4147.105
Firefox: 72.0.1
Safari: 13.1.2
npmPackages:
gatsby: 2.24.9 => 2.24.9
gatsby-image: ^2.4.13 => 2.4.13
gatsby-plugin-postcss: ^2.3.11 => 2.3.11
gatsby-plugin-react-svg: ^3.0.0 => 3.0.0
gatsby-plugin-sharp: ^2.6.22 => 2.6.22
gatsby-source-filesystem: ^2.3.7 => 2.3.22
gatsby-source-wordpress-experimental: 1.0.7 => 1.0.7
gatsby-transformer-sharp: ^2.5.11 => 2.5.11
gatsby-wordpress-experimental-inline-images: ^0.0.3 => 0.0.3
npmGlobalPackages:
gatsby-cli: 2.12.63

@doingandlearning doingandlearning added the type: bug An issue or pull request relating to a bug in Gatsby label Aug 4, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 4, 2020
@freiksenet freiksenet added topic: admin and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 4, 2020
@polarathene
Copy link
Contributor

Is the error you encounter like this?

$ gatsby develop

Something is already running at port 8000
✔ Would you like to run the app at another port instead? … yes

 ERROR 

Looks like develop for this site is already running. Try visiting http://localhost:8000/ maybe?

If so it might be related to either of these PRs: #25863 #25915

You could try testing with gatsby 2.24.7 I think as a version prior to those. Although since it doesn't appear to be a false positive, perhaps that's not the case and it's something else. As you can't kill the process, perhaps it's a zombie process..

@mxstbr
Copy link
Contributor

mxstbr commented Aug 11, 2020

This appears to be an issue with our service discovery mechanism not correctly releasing locks on CTRL+C. While I don't know how to resolve that, we already use the minimum possible stale duration for the lockfiles of 5s so after five seconds it should work again:

const lockfileOptions = {
// Use the minimum stale duration
stale: 5000,
}

That means we could quickly patch this annoyance for users by changing the error log to something like "Looks like develop for this site is already running, can you visit http://localhost:8000? If it is not, try again in five seconds!"

@lumenwrites
Copy link

I'm getting the error:

Looks like develop for this site is already running, can you visit http://localhost:8000 ? If it is not, try again in five seconds!

I have tried killing all the node processes, deleting .cache/ and public/, even restarting my laptop - I'm still getting the same error. It's really weird. When I open http://localhost:8000, nothing is running there.

Can someone help me figure out what's wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants