gemini-testing / gemini-gui

GUI for gemini
MIT License
69 stars 18 forks source link

Ctrl-C doesn't terminate gemini-gui server when running through npm run #81

Open shamrin opened 7 years ago

shamrin commented 7 years ago

Steps

  1. npm install --save-dev gemini-gui
  2. configure gemini to use chromedriver
  3. add npm run test:gui command to package.json:
{
  // ...
  "scripts": {
    "test:gui": "gemini-gui -p 8076 ./gemini",
  }
}
  1. launch gemini-gui through npm run test:gui
  2. click Run button to run tests
  3. hit Ctrl-C in the server console

Expected

gemini-gui server is terminated

Actual

npm run script is terminated, but gemini-gui is still running and occupies the port forever

Logs

$ grep test:gui package.json
    "test:gui": "gemini-gui -p 8076 ./gemini",
$ npm run test:gui

> somepkg@1.0.0 test:gui /Users/user/src/somepkg
> gemini-gui -p 8076 ./gemini

GUI is running at http://localhost:8076
✓ somepkg home [chrome]
Total: 1 Passed: 1 Failed: 0 Skipped: 0 Retries: 0
^CCancelling...
$ npm run test:gui

> somepkg@1.0.0 test:gui /Users/user/src/somepkg
> gemini-gui -p 8076 ./gemini

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE 127.0.0.1:8076
    at Object.exports._errnoException (util.js:1022:11)
    at exports._exceptionWithHostPort (util.js:1045:20)
    at Server._listen2 (net.js:1259:14)
    at listen (net.js:1295:10)
    at net.js:1405:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)

Address is indeed still in use:

$ lsof -PiTCP -sTCP:LISTEN | grep 8076
node      85382 user   15u  IPv4 0xdeadbeef12345      0t0  TCP localhost:8076 (LISTEN)

Curiously, it prints Force quit when killing the process:

$ kill 85382
Force quit.

(The problem is even more confusing because of #2)

niedzielski commented 7 years ago

Thanks for filing this ticket. I'm seeing this same issue:

$ gemini-gui .
# The user must now run tests in the GUI or the bug won't surface.
# ...test output...
# ...test output...
# ...test output...
^CCancelling...

At this point, the command hangs forever or until ctrl-c is pressed again. However, when executed through NPM, the issue is even more confusing and problematic:

...,
"scripts": {
  ...,
  "test:gemini-gui": "gemini-gui ."
  ...
},
...
$ npm run -s test:gemini-gui
# The user must now run tests in the GUI or the bug won't surface.
# ...test output...
# ...test output...
# ...test output...
^CCancelling...

Unlike when executed directly, the NPM command appears to terminate after "Cancelling..." but Gemini GUI is actually still running in the background because it ignores the initial SIGINT. This causes the port to stay open. The issue appears to be in Gemini itself, not the GUI.