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

Chrome randomly hangs, trying to load URL that isn't served #216

Open
srsudar opened this issue Oct 27, 2019 · 3 comments
Open

Chrome randomly hangs, trying to load URL that isn't served #216

srsudar opened this issue Oct 27, 2019 · 3 comments

Comments

@srsudar
Copy link

srsudar commented Oct 27, 2019

Roughly 50-80% of the time, when I run karma Chrome starts but the tests never run. Instead Chrome waits, trying to load a URL like http://localhost:9876/?id=36448760. Unlike with #63, however, if I load that URL in a different Chrome instance, it too never loads.

I've tried adding loglevel: config.LOG_DEBUG, but it doesn't add anything that looks relevant to me.

Can you give me any additional pointers on what I might debug? I've tried everything I can think of and can't seem to get past this. Some output is provided below.

The output that does nothing looks like this:

<snip>
26 10 2019 21:37:51.005:INFO [karma-server]: Karma v4.3.0 server started at http://0.0.0.0:9877/
26 10 2019 21:37:51.006:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
26 10 2019 21:37:51.011:INFO [launcher]: Starting browser Chrome
26 10 2019 21:37:51.011:DEBUG [launcher]: null -> BEING_CAPTURED
26 10 2019 21:37:51.011:DEBUG [temp-dir]: Creating temp dir at /var/folders/q_/1xnp_rt10rn_nwjj3tsfdd9w0000gp/T/karma-68911545
26 10 2019 21:37:51.011:DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/q_/1xnp_rt10rn_nwjj3tsfdd9w0000gp/T/karma-68911545 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications http://localhost:9877/?id=68911545

The output when it works looks like this. It appears to just proceed from where the previous output hangs:

26 10 2019 21:45:23.478:INFO [karma-server]: Karma v4.3.0 server started at http://0.0.0.0:9877/
26 10 2019 21:45:23.478:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
26 10 2019 21:45:23.484:INFO [launcher]: Starting browser Chrome
26 10 2019 21:45:23.484:DEBUG [launcher]: null -> BEING_CAPTURED
26 10 2019 21:45:23.484:DEBUG [temp-dir]: Creating temp dir at /var/folders/q_/1xnp_rt10rn_nwjj3tsfdd9w0000gp/T/karma-97310113
26 10 2019 21:45:23.485:DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/q_/1xnp_rt10rn_nwjj3tsfdd9w0000gp/T/karma-97310113 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-background-timer-throttling --disable-renderer-backgrounding --disable-device-discovery-notifications http://localhost:9877/?id=97310113
26 10 2019 21:45:24.682:DEBUG [web-server]: serving: /Users/snip/extension/node_modules/karma/static/client.html
26 10 2019 21:45:25.089:DEBUG [web-server]: serving: /Users/snip/extension/node_modules/karma/static/karma.js
26 10 2019 21:45:25.435:DEBUG [karma-server]: A browser has connected on socket z2z8zaBlesYe5sSpAAAA
26 10 2019 21:45:25.446:DEBUG [web-server]: upgrade /socket.io/?EIO=3&transport=websocket&sid=z2z8zaBlesYe5sSpAAAA
26 10 2019 21:45:25.476:DEBUG [Chrome 77.0.3865 (Mac OS X 10.15.0)]: undefined -> CONNECTED
26 10 2019 21:45:25.476:INFO [Chrome 77.0.3865 (Mac OS X 10.15.0)]: Connected on socket z2z8zaBlesYe5sSpAAAA with id 97310113
26 10 2019 21:45:25.477:DEBUG [launcher]: BEING_CAPTURED -> CAPTURED
26 10 2019 21:45:25.478:DEBUG [launcher]: Chrome (id 97310113) captured in 1.999 secs
26 10 2019 21:45:25.478:DEBUG [karma]: All browsers are ready, executing
26 10 2019 21:45:25.478:DEBUG [karma]: Captured 1 browsers
26 10 2019 21:45:25.515:DEBUG [web-server]: serving: /Users/snip/extension/node_modules/karma/static/favicon.ico
26 10 2019 21:45:25.525:DEBUG [middleware:karma]: custom files null null null
26 10 2019 21:45:25.525:DEBUG [middleware:karma]: Serving static request /context.html
@mschwartau
Copy link

mschwartau commented Nov 22, 2019

Had a similar issue and wrote a blog post about how I analyzed it:
https://blog.schwartau.hamburg/2019/11/troubleshooting-karma-node-performance-problems/

Using the node profiler and dtrace / dtruss (mac os version of strace) I found out that compilation of the scss files took a lot of time. After overwriting the scss files with empty files the performance problems vanished.

If scss files are not the problem by using of the node profiler and strace / dtruss you should be able to find out what causes the problem (see blog post).

@srsudar
Copy link
Author

srsudar commented Mar 30, 2020

Thanks for the suggestion and the great blog post. I fell off the wagon on this project but got back around to it today.

Unfortunately there isn't anything obvious in my profile that makes it look like it is spinning its wheels. I managed to capture both a run that never loaded (just spun eternally as I describe above) and a run that worked. I can't tell anything obviously different between the two runs. The one that never worked has no javascript entries, while the one that did work has entries:

Tests ran:

 [JavaScript]:
   ticks  total  nonlib   name
      1    0.3%    0.4%  LazyCompile: *normalizeString path.js:52:25

Tests didn't run:

 [JavaScript]:
   ticks  total  nonlib   name

But otherwise things look roughly the same. 2 ticks in a shared library /usr/lib/system/libsystem_malloc.dylib on the one that worked that are missing in the one that hung.

Do you happen to have any other suggestions? It looks like whatever web server karma is starting isn't working for some reason. I'd love another way to try and debug that.

@srsudar
Copy link
Author

srsudar commented Mar 30, 2020

Interestingly, I just noticed that if I sent singleRun: true in my karma.conf.js, I never have this problem. The tests always seem to run and then Chrome closes, as expected. So maybe it is due to trying to stay open, somehow...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants