WebPagetest Forums
Test Error: Unexpected token a - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Bugs/Issues (/forumdisplay.php?fid=10)
+--- Thread: Test Error: Unexpected token a (/showthread.php?tid=13233)



Test Error: Unexpected token a - sidbala - 09-10-2014 05:50 AM

I have a private instance with real iOS devices. I am getting this strange error when running tests on iOS agents. "Test Error: Unexpected token a"

No further information is presented. Any ideas on what might be causing this? It is also intermittent, and I cannot seem to narrow it down to network connectivity issues.

How do I go about debugging the nodejs agents?


RE: Test Error: Unexpected token a - pmeenan - 09-11-2014 12:09 AM

The output should give you a call stack to the line of code that generated the message/exception. If you run the agent with -m debug it should produce a log that has a lot of information about exactly what is going on.

Beyond that it's usually a matter of adding more logging to narrow it down (good ole printf debugging basically). It's possible you could run the agent inside an IDE like webstorm but I haven't had much luck with that the one time I tried.


RE: Test Error: Unexpected token a - andydavies - 09-11-2014 03:15 AM

Pat, out of interest is it possible to debug the Node agent with Node Inspector?

Don't worry if you don't know, I'll try it at somepoint


RE: Test Error: Unexpected token a - pmeenan - 09-11-2014 03:49 AM

Sorry, don't know but would love to hear what you find. I've been falling back to printf debugging so any better option would be very appreciated.


RE: Test Error: Unexpected token a - sidbala - 09-11-2014 12:11 PM

Thanks for the -m debug option. I managed to get a callstack.

E Sep_10_09:51:13.739 wd_server.js:1013 WebDriverServer.done_ : Run failed, stopping: SyntaxError: Unexpected token a
at Object.parse (native)
at DevTools. (/Users/sidbala/Gits/webpagetest/agent/js/src/devtools.js:96:33)
at IncomingMessage. (/Users/sidbala/Gits/webpagetest/agent/js/src/devtools.js:46:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:919:16
at process._tickCallback (node.js:419:13)

It seems that the IOSWebKitDebugProxy is sending non JSON data on it's JSON interface. The parser fails when it finds the first token 'a' in that output. I've added additional logging to output the message it is trying to parse.

I did manage to use node-debug at some time ago with the nodejs agents. However, I was not able to break on breakpoints. So it ended up being essentially a elaborate text editor.

Just resorting to printf debugging now.


RE: Test Error: Unexpected token a - pmeenan - 09-11-2014 10:11 PM

If you can get a message dump (or if there is a way to get the proxy to log everything) I highly recommend opening a github issue for the proxy. Todd is quite responsive to looking into issues and there are also a lot of other users (mostly using it with webdriver or Chrome) that may have already dug into it.


RE: Test Error: Unexpected token a - sidbala - 09-12-2014 05:43 AM

Cross ref to GitHub issue: https://github.com/WPO-Foundation/webpagetest/issues/297

I'll see what I can do about the logging. Right now I just printf out the exact response from the proxy. The issue has not yet manifested. It was very intermittent to begin with.


RE: Test Error: Unexpected token a - sidbala - 09-12-2014 11:24 AM

I think I have nailed down the specific issue.

When the node agent connects into Safari, and there is already a tab open with some content, it receives the following through the JSON interface.

The Response Body is:[{
"devtoolsFrontendUrl": "/devtools/devtools.html?host=localhost:1142&page=1",
"faviconUrl": "",
"thumbnailUrl": "/thumb/http://sfbay.craigslist.org/search/ppa?query=air+conditioner+%7C+a%2Fc",
"title": "SF bay area appliances "air conditioner | a/c" - craigslist",
"url": "http://sfbay.craigslist.org/search/ppa?query=air+conditioner+%7C+a%2Fc",
"webSocketDebuggerUrl": "ws://localhost:1142/devtools/page/1"
}]

Notice how the title value has double quotations inside it that are not escaped. This is invalid JSON. So this seems like an issue with iOSWebKitDebugProxy. I'll see if they've fixed this issue in any of their latest commits (although the latest commit is from 2 months ago).