Current time: 06-21-2018, 08:27 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Test Error: Unexpected token a
09-10-2014, 05:50 AM
Post: #1
Test Error: Unexpected token a
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?
Find all posts by this user
Quote this message in a reply
09-11-2014, 12:09 AM
Post: #2
RE: Test Error: Unexpected token a
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2014, 03:15 AM (This post was last modified: 09-11-2014 03:16 AM by andydavies.)
Post: #3
RE: Test Error: Unexpected token a
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

Andy

Using WebPageTest - http://usingwpt.com/
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2014, 03:49 AM
Post: #4
RE: Test Error: Unexpected token a
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-11-2014, 12:11 PM
Post: #5
RE: Test Error: Unexpected token a
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.
Find all posts by this user
Quote this message in a reply
09-11-2014, 10:11 PM
Post: #6
RE: Test Error: Unexpected token a
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-12-2014, 05:43 AM
Post: #7
RE: Test Error: Unexpected token a
Cross ref to GitHub issue: https://github.com/WPO-Foundation/webpag...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.
Find all posts by this user
Quote this message in a reply
09-12-2014, 11:24 AM
Post: #8
RE: Test Error: Unexpected token a
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).
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)