Check why ruby script hangs

前端 未结 2 1438
春和景丽
春和景丽 2020-12-15 11:34

Sometimes my specs can just hang and I have to kill the corresponding ruby process. It\'s quite common when I run integration specs written with capybara and webkit driver.<

2条回答
  •  时光取名叫无心
    2020-12-15 12:24

    I had this problem as well and traced it to a ShareThis javascript widget on a particular page. You may or may not be using this, but the real problem is perhaps its hanging because something on the page is causing an external request that never finishes. Capybara-webkit will know about the original request, but if this code itself makes a request, capybara-webkit will never know about it, and if that last request hangs, say waiting for a response, so will capybara-webkit...

    For you, run the test using webkit-debug and look at the very last request that is made. For me, i saw the following:

        1 requests remaining 
        Page finished with true 
        Received 200 from "http://w.sharethis.com/share4x/js/st.60709d5fdf0c137e879e64f41b8a6606.js" 
        0 requests remaining 
        Started request to "http://w.sharethis.com/share4x/css/share.470030190b6a6bdc89365fcc74d3bf55.css" 
        Received 200 from "http://w.sharethis.com/share4x/css/share.470030190b6a6bdc89365fcc74d3bf55.css" 
        0 requests remaining 
    

    And that clued me to search my codebase for ShareThis. I put an if(Rails.env.test?) block around that code, and voila, i'm in business. Its a crappy workaround to have to put conditionals for test environments into your codebase...but it got me moving on from this silly problem...

    Hope this helps.

提交回复
热议问题