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.
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.
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.
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.
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.
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).