juliangruber / browser-run

Run code inside a browser from the command line
447 stars 62 forks source link

Browsers other than electron don't close #152

Open fregante opened 4 years ago

fregante commented 4 years ago

I noticed when using tape-run that Firefox closed but Chrome stayed open (even though the tests completed anyway)

However this doesn't close the tab and window either:

echo "console.log('Hey from ' + location); window.close()" | browser-run --browser firefox

...nor any other browser I tested: chrome and safari.

The interesting part is that this closed the tab once, but on a second call the tab and window stayed open:

echo "var run = require('browser-run');
  var browser = run({browser: 'chrome'});
  browser.pipe(process.stdout);
  browser.end('console.log(location); window.close()');" | node

I'm on macOS 10.15.2, Node v12.14.1

ashnur commented 4 years ago

closing chrome is notoriously hard, i've had issue elsewhere and others too with similar problems (just search on github for chrome not closing or kill chrome, or anywhere)

this might or might not be helpful https://unix.stackexchange.com/questions/139830/kill-stop-all-google-chrome-processes

fregante commented 1 year ago

I ended up running it with a timeout:

Via cli this is possible as:

timeout 5m npm run tests

Or on macOS: https://stackoverflow.com/questions/3504945/timeout-command-on-mac-os-x