Friday, May 17, 2024
148
rated 0 times [  152] [ 4]  / answers: 1 / hits: 61910  / 9 Years ago, tue, september 8, 2015, 12:00:00

I was not clear in my problem description. Let me try again.



NB. This is a problem common to my production, staging, and development sites (not just to my delevlopment site as the commenters seem to have thought).



NB. This problem occurs bowsing with Chrome and not with Firefox.



The problem occurs at the site home page: http://www.example.com (or with /index.php appended). The page loads successfully, but the Console pannel of Chrome's Developer Tools shows a 404 error. The message reads GET http://www.example/undefined 404 (Not Found). It always shows the error as occuring at (index):1 which is the DOCTYPE line. Whatever is generating the problem, it is not that.



The page is loading fine, I just get this odd message in the Developers Tools Console. (I probably wasn't clear about that in the original problem description.) Firfox's console shows no such error.



I want to track down what is generating this error. In particular, I would like to find where Chrome is getting the undefined url. My guess (but only a guess) is that one of my many Javascript files is genrating a URL from an undefined variable. Chrome's location of the problem, (index):1, is wrong. I would appreciate any ideas as to how to get a more useful error message out of Chrome: the name of the file where the URL was found would help. If I can do this without having set breakpoints in all my Javascript files one by one, that would be particularly nice. :-)



The original question with URL's removed (I'm limited in the number of links I'm allowed with a reputation < 10) follows. You may not want to read it as people have been confused by it.




We have rather complex Drupal website. When going to the homepage,
the Chrome (Version 45.0.2454.85 m) Console shows me an error: [URL
removed] 404 (Not Found) (index):1. (I'm using the development site
on my local computer because minification is turned off there.)

Okay, I think, I know what to do about that: Go find the offending
spot in whatever file, scratch my head a few times, get a brilliant
idea, and fix the problem. One little difficulty: the problem is
surely not occurring at index, line 1 (which I assume is what
(index):1 means). The undefined in the error message suggests but
does not prove that the offender is one of our about a dozen
JavaScript files. Presumably some variable somewhere is undefined.
So how do I get Chrome to cough up the location where the offense is
occurring? It is not giving me any undefined value JavaScript errors,
just a 404 on [URL removed]/undefined . Thanks in advance for any
ideas.



Edit: I forgot to add that Firefox is showing no such error.



More From » google-chrome

 Answers
29

I found where this issue could appear from.




  1. Make sure that all the generated CSS (styles) that set a background-image or the like, where there's an url() actually point somewhere; if it doesn't point anywhere the error will set to the .html DOCTYPE.

  2. Check the src of your image tags; make sure that they are not set by JavaScript to undefined.

  3. Also check the src of your script files, even when it'd be much rarer in that case to happen.



So yes it's awful that it actually doesn't point where the actual error is but in fact has to be with a lookup resource that it isn't able to find; we probably don't even want it to search. Eg. when the element is invisible and we don't set any image; but we still pass undefined it'll search for undefined and it'll not give you any hint of in which part of the tree the error is.



Since your page is too complex to know where it is, or if this is even the problem you are facing; this is the most I can tell; the only reason I could find it too quick was because of react dev tools told me right away of my render properties and the fact that the component was quite small.


[#65138] Monday, September 7, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
luzv

Total Points: 178
Total Questions: 105
Total Answers: 114

Location: Palau
Member since Tue, May 30, 2023
1 Year ago
;