Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript errors when using Google App Engine's Channel API and development server

I'm writing a Python GAE app that uses the Channel API, and everything works fine except that I get non-fatal browser errors in the Firefox error console when using the development server. It's essentially the same with every Channel API application, so I'll show what I see with the sample Channel Tac Toe app.

It starts with a syntax error, where the source code shown is always just the digit "1":

Error: syntax error
Source File: http://localhost:8080/_ah/channel/dev?command=connect&channel=channel-2053758219-1329727351-185804764220139124118185804764220139124118
Line: 1, Column: 1
Source Code:1

Next is a "not well-formed" error (only in Channel Tac Toe):

Error: not well-formed
Source File: http://localhost:8080/_ah/channel/dev?command=poll&channel=channel-2053758219-1329727351-185804764220139124118185804764220139124118&client=1
Line: 1, Column: 1
Source Code:{"winner": null, "userX": "185804764220139124118", "moveX": true, "winningBoard": null, "board": "         ", "userO": ""}

Then I get an endless series of "no element found" errors, about three a second:

Error: no element found
Source File: http://localhost:8080/_ah/channel/dev?command=poll&channel=channel-2053758219-1329727351-185804764220139124118185804764220139124118&client=1
Line: 1

After this, Channel Tac Toe behaves badly (both sides want to be the X player) although my actual application runs without problems.

Note that because these are all JavaScript errors there's no stack trace.

(a) What's causing these problems? Although my application runs, these errors lower my confidence.

(b) The endless series of "no element found" messages is a real problem, as they make it very difficult to see other JavaScript errors.

I have come across one other report of the same problem, but the follow-up was unhelpful.

My configuration: Windows 7, Firefox 10.0.2 (add-ons disabled), GAE 1.6.2

like image 402
Dragonfly Avatar asked Nov 26 '22 03:11

Dragonfly


1 Answers

FWIW, the problem appears to be caused by the Channel API's internal polling mechanism not receiving responses from the server that include a Content-type. As a result, Firefox seems to default the response's content type to text/xml.

The "no element found" error is likely thrown when Firefox attempts to generate the XMLHttpRequest.responseXML property[1] -- because the response body is actually blank and so no root XML element was found.

[1] https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#responseXML

like image 123
Nate Whittaker Avatar answered May 16 '23 07:05

Nate Whittaker