Sencha Touch JSONP error-Collection of common programming errors

EDIT:

I came across a confirmation of what I suspected: Using the twitter search API with JSONP causes the problem in isolation, so it seems that something is going wrong with Twitter.

See: http://search.twitter.com/search.json?q=%23jimromeisburning&callback=dog

About 3/5 times, as of 3:44PM CT on 14 June, Twitter returns garbage. The rest of the time, it returns a valid javascript function call.

I’m using Sencha Touch to make a JSONP request to the Twitter search API, and about 1/100 times, I’m getting a javascript error that kills further polling:

Uncaught SyntaxError: Unexpected token ILLEGAL

So far I’ve tried the following with no leads:

  1. Wrapping the call to Ext.util.JSONP.request({}) in a try/catch block. Doesn’t catch the error (presumably because it’s being called from a script tag in an iframe)
  2. Dumping the query parameter passed into JSONP.request to make sure that it’s valid. It is.
  3. Looking for a pattern– it seems to happen at unexpected times. Could be the very first request, or it could be 100 requests down the line.

My best guess is that Twitter is sending back garbage some of the time. That’s ok, I just need a way to handle that error. Unfortunately, as far as I can tell, Sencha Touch doesn’t have any built-in error handling for its JSONP requests.

Have you seen anything like this before? Do you have any ideas?

Thanks!

Here’s what the ornery JSONP script response looks like:

Ext.util.JSONP.callback(?Ro?6?
?`)???k?em??+?`?
-?-??RT??w?????$v?-A^????Ow?|?4Tua*+????????????Vbs???5?/
??[?o????N?E9????*??N3?1j;QRI®T??E?r4??S
?@??w|??!a.???g?%?????@??*????>Z8^_h???z>u]?E????V??u?k&#@k
)Hc}=???;o%?.
?????L??5?T?B*????????{????z?M???.}/dm?=????5i?KA??y????Q?n???n????
??x???R?N???q?k??

Originally posted 2013-11-16 20:53:14.