twolfson / karma-electron

Karma launcher and preprocessor for Electron
The Unlicense
59 stars 21 forks source link

Report error reason starting electron #22

Closed stephennancekivell closed 7 years ago

stephennancekivell commented 7 years ago

Hi, thanks for karma-electron.

I dont think karma-electron is reporting startup errors from electron, which would be nice to do.

One example is if libgtk2.0-0 isnt installed. When running karma from npm run all it shows is the message Cannot start Electron, but if you run electron on its own it will give more descriptive stack trace. libgtk2.0-0 not found.

I would think you can redirect stderr to get this..

Karma message

ERROR [launcher]: Cannot start Electron
ERROR [launcher]: Electron failed 2 times (cannot start). Giving up.

expected

ERROR [launcher]: Cannot start Electron
ERROR [launcher]: Error from electron. libgtk2.0-0.so not found
ERROR [launcher]: Electron failed 2 times (cannot start). Giving up.
twolfson commented 7 years ago

This is a problem in Karma itself, not our library specifically =/ Here's a gist demonstrating the same issue but in Firefox in a Docker container:

https://gist.github.com/twolfson/f099e18cf5eb9cc55384e7a0582fbe10

Karma message:

root@85de9cecee79:/docker# npm test

> gist-karma-launcher-fail@1.0.0 test /docker
> FIREFOX_BIN=$PWD/vendor/firefox/firefox karma start

30 03 2017 04:00:46.897:INFO [karma]: Karma v1.5.0 server started at http://0.0.0.0:9876/
30 03 2017 04:00:46.899:INFO [launcher]: Launching browser Firefox with unlimited concurrency
30 03 2017 04:00:46.906:INFO [launcher]: Starting browser Firefox
30 03 2017 04:00:46.922:ERROR [launcher]: Cannot start Firefox

30 03 2017 04:00:46.929:INFO [launcher]: Trying to start Firefox again (1/2).
30 03 2017 04:00:46.936:ERROR [launcher]: Cannot start Firefox

30 03 2017 04:00:46.940:INFO [launcher]: Trying to start Firefox again (2/2).
30 03 2017 04:00:46.949:ERROR [launcher]: Cannot start Firefox

30 03 2017 04:00:46.952:ERROR [launcher]: Firefox failed 2 times (cannot start). Giving up.

Running Firefox directly:

root@85de9cecee79:/docker# ./vendor/firefox/firefox
XPCOMGlueLoad error for file /docker/vendor/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.

We've received this issue before in #17 and I'm almost certain I've encountered it before (e.g. when setting up this repo in Travis CI). I'm going to see if there are any existing Karma issues to resolve this

twolfson commented 7 years ago

There seems to be https://github.com/karma-runner/karma/issues/2465 but no PRs to resolve it. It's not exactly what we want as it requries opt-in but I feel like it would be close enough for PRs.

I've found a reasonable patch for our behavior which I'll submit briefly

twolfson commented 7 years ago

Alright, we've opened up https://github.com/karma-runner/karma/issues/2639. I'm going to close this issue since it's outside of karma-electron's scope

stephennancekivell commented 7 years ago

Legend! thanks @twolfson

twolfson commented 7 years ago

Good news! Our patch has been landed/released in karma@1.6.0 :tada: