Mon, 02 Jul 2012
404: /undefined
In IS MU, we log and evaluate errors in HTTP
requests, including "404 not found". When the Referrer
header
points back to our site, we try to look for a broken link.
Recently (last month or so), strange 404 requests started to appear in our
log file:
These requests point to the location /undefined
, with referrer
being our root document, /
. And the referrer is not fake,
there is always a successful request to /
from the same IP
address from several seconds ago. Occasionally we get similar 404 requests,
pointing to /lide/undefined
, or /vyhledavani/undefined
,
with referrer being /lide
, or /vyhledavani
.
We are not able to reproduce the problem. It is not User-Agent-specific
(altough most of the User-Agents with this problem are Chrome), and it
is not deterministic: we got tens of these 404 requests daily out of
milions total requests (and out of tens of thousands of requests to the
title page). These requests are always for a non-authenticated page, and
always for a page which is a directory (i.e. which is represented by the
index.html
or index.pl
document in that directory).
I think it is related to some Javascript we include to the title page - maybe JQuery, maybe Google Analytics. I have tried to remove the Google Analytics Javascript from our title page for a day, but it did not make the problem disappear. Also, our git log from the time these requests started to appear does not show anything related. We have found the following possibly related discussions:
- http://productforums.google.com/forum/#!category-topic/analytics/discuss-tracking-and-implementation-issues/oqEgEM3rc8M
- http://stackoverflow.com/questions/11017609/undefined-randomly-appended-in-1-of-requested-urls-on-my-website-since-12-jun
So, my dear lazyweb - any ideas what can be the cause of this behaviour?
UPDATE 2012/07/03: It is probably AJAX
Yesterday have added a new image to the 404 page which meets the above
conditions (location ending with "/undefined
",
referrer being the location minus "/undefined
"), and
so far after > 12 hours I see exactly zero accesses to that image
in my Apache logs. So this error is most probably caused by something
that users can't see, i.e. AJAX requests. Not the window.location
modification that himdel suggests in the coments.
2 replies for this story:
himdel wrote:
I think it's the autocompletion .. or, more specifically, ancient jQuery:
- go to /lide/
- there's this result handler: var span = document.createElement('span'); span.innerHTML = item[0]; window.location = $(span).find("a").attr("href") + url_params;
- span gets set to <span></span>
- but $(span) yields null
- null has no find method, so the while $(span).find... expression yields undefined
- window.location = 'undefined' goes to /lide/undefined
Yenya wrote: Re: himdel
Thanks, I will look at the autocompletion. But this would mean item[0] was set to an empty string. Moreover, I don't see any request to autocompletion (/naseptavac_data.pl) in my access logs before the request to /undefined is made.