Chrome just doesn't finish loading JS files

31,127

Solution 1

One possibility is that you have Keep-Alive enabled and it is not working properly. I've seen this before. The browser establishes it's maximum number of connections to your server (typically 6) to download the first few files (CSS, JS etc.) then those connections are not released until they time out. My symptoms were not quite the same as yours - the timeout was 20 seconds and everything would load in batches of 6 after that - but this could still be the cause.

In your Apache configuration (httpd.conf on most systems), look for the KeepAlive line (or add it if it's missing) and set it to Off.

Solution 2

More than an answer, here's how I would troubleshoot the problem.

One of the things I'd try is commenting out tags one at a time and reload, to see where the threshold is. Also, because this is probably a server configuration problem, I'd restart it after each try, to have a clean slate, so to speak, i.e., no state preserved between tries.

I'd try to get more hints by trying to make the requests for the various Javascripts from a script in your favourite language. Ideally, I'd try GETting the scripts one by one (say with curl) waiting a few milliseconds between requests. I imagine I'd hit a threshold here as well. Like, getting one script per second works, but when requests get too close, the server gets stuck.

If still no clue, I'd use tcpdump to watch the traffic between the browser and the server. Okay, this may be a little too low level!

But perhaps I'd use netstat to see how many connections the browser opens in parallel to the server to fetch the resources, and see if we hit a concurrency limit.

I'm sorry this is a solution but I hope you get some ideas, and I'd be very curious to know what your problem is, in the end!

Solution 3

We got exactly the same message "Caution: request is not finished yet" after a request in the browser.

The request itself was in the order of 15 MB of JSON, which was fed into an Angular 1 application. This request took about 2 seconds. Right after the request was finished, the Angular digest cycle blocked the browser for more than 12 seconds (this is visible by profiling during the request). During that time Chrome showed this "Caution: request is not finished yet" message in request whilst it actually was already finished.

Solution 4

Check the Content-Length header. Server may pass incorrect value - greather than actual content length.

Solution 5

Try to emulate problem in https://www.stevesouders.com/cuzillion/ It should say you side of problem - chrome or server

Share:
31,127

Related videos on Youtube

KJ Saxena
Author by

KJ Saxena

Founder of Autoninja Teaches Venture Capital & Entrepreneurship at IIM Bangalore Invests in startups through Relentless VC Sometimes tames Dragons

Updated on February 23, 2020

Comments

  • KJ Saxena
    KJ Saxena about 4 years

    I am writing an app that includes about 12 short JS files in the <head> section (I know, I should merge them and move them just before the end of <body>; would get to those when in production)

    The trouble is that when I try to load the app in Chrome, Some files load immediately while some never finish loading at all! Chrome keeps trying to load the 12 JS files and never renders the page until I hit "Stop".

    When I hit stop, the HTML is rendered and the JS files fail as in the image below:

    JS Load errors

    Note that different JS files fail on each attempt! It's not the same file that gets stuck every time!

    Inspecting the headers of the failed files shows "Caution: request is not finished yet". The files are stuck in "Receiving" sometimes for many minutes!

    enter image description here

    Now here's the fun part, after hitting stop, if I focus on the omnibar and press enter, all the JS files load instantly and the application works fine!

    On the server side, I am using Apache, PHP and MySQL. Have I misconfigured something in Apache?

    STATUS after 2 gruelling days: zilch, nothing, nada, this is driving me nuts. I have tried running the code from different machines, have tried changing apache cache settings and changed myriad things in javascript but nothing has worked. The worst thing is that no one can pin point where the problem is!

    • evolutionxbox
      evolutionxbox over 9 years
      Try turning off some of your chrome extensions. Adblock has been known to interfere with development.
    • KJ Saxena
      KJ Saxena over 9 years
      All extensions are blocked. Hasn't any one faced something like this before? And why the down vote? I am yet to find a solution anywhere!
    • evolutionxbox
      evolutionxbox over 9 years
      Have you tried hosting the files elsewhere? Maybe there's some sort of mime-type issue? (I didn't down vote).
    • KJ Saxena
      KJ Saxena over 9 years
      I didn't understand what you meant by mime-type issue. Could you please elaborate?
    • KJ Saxena
      KJ Saxena over 9 years
      Wow! everyone is so opinionated that this is BAD question but no one has an answer!
    • Clément Malet
      Clément Malet over 9 years
      @KshitijSaxena-KJ- Can you show the HTML part where the JS script are added ? (Well, the <head> content)
    • evolutionxbox
      evolutionxbox over 9 years
      Sorry @KshitijSaxena-KJ-. The problem you're having is unlikely to be related to file mime-types. I would assume that the problem is server side, especially if you have no trouble accessing other websites. Also, I have no idea why people are down-voting the question...
    • Birgit Martinelle
      Birgit Martinelle over 9 years
      Why do you include them in your head and not before the end body-tag as you said you would in production? Does it happen then too?
    • bancer
      bancer over 9 years
      3.5 min to load minified jquery - something is really wrong here. Do you experience that problems only in Chrome? What happens in Firefox?
    • dmo
      dmo over 9 years
      Have you tried on another browser like Safari or Moz?
    • dmo
      dmo over 9 years
      Have you tried commenting out or deleting each include, reload and see if you get the same problem
  • dykzei eleeot
    dykzei eleeot over 6 years
    Can you elaborate on "keep-alive" not working properly? How would it cause the issue? I'm having the same problem with IIS.
  • Chagai Friedlander
    Chagai Friedlander about 4 years
    Hey, can you elaborate on "profiling during the request"? I think I have the same issue but I want to make sure of it
  • Jos de Jong
    Jos de Jong about 4 years
    Hm it has been a while. I think it was like: start the profiler of your browser, then load the page, and stop the profiler after the request is finished and the application is rendered.
  • Alireza
    Alireza almost 4 years
    The Link is dead