Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$http responseType: 'json' triggers DOM Exception 12 in Mobile Webkit #6115

Closed
quantizor opened this issue Feb 4, 2014 · 7 comments
Closed

Comments

@quantizor
Copy link

Hi folks,

I'm building a nice little drag & drop upload form for a contest and came across an interesting error.

In trying to perform a simple $http.get call with some config passed, I've been getting DOM Exception 12 "SYNTAX ERROR" only in mobile phones with webkit-based browsers. Chrome does not seem to be affected.

Here's the actual code to reproduce (found in v1.2.6):

$http.get('/api/contest/submit.action', { params: $s.fields, responseType: 'json' }).then(function( response ){
    $s.submitted = true;
});

Has anyone else run into this? The DOM error points to the line in $http's source where it sets the xhr.responseType property.

@caitp
Copy link
Contributor

caitp commented Feb 4, 2014

responseType is from XMLHttpRequest2, which probably isn't supported on mobile safari 7 or something.

That said, I don't see anything in the IDL which would cause it to throw for setting the response type, it should probably just be ignored.

Any any rate, I can't seem to reproduce this on mobile Safari 7. Could you post a reproduction and list the affected devices+browsers you've tested with?

edit I can reproduce this with mobile safari 6.1 in ios simulator

@quantizor
Copy link
Author

I saw this on an iPhone 4S running iOS 6.1.3. I had a coworker come by with an iPhone 5 and iOS 7 and report the same issue. I ended up just removing the responseType declaration, as Angular seems to do JSON conversion by default, but just wanted to raise the issue in case it was a red flag for a deeper problem.

@caitp
Copy link
Contributor

caitp commented Feb 4, 2014

It seems that the exception gets thrown when assigning xhr.responseType (although I see no reason in the IDL why that should happen!)

We could get around this by wrapping it in a try/catch block (but I don't really like this idea)

@caitp
Copy link
Contributor

caitp commented Feb 4, 2014

It looks like safari 6.1 doesn't support the "json" responseType. http://trac.webkit.org/changeset/154992 was checked in only a couple months ago, and I guess the 6.1 release didn't include that patch. So this explains it.

For what it's worth though, if you just use responseType="text" or ignore the responseType setting entirely, angular will automatically parse JSON for you. (which apparently you've already mentioned!)

@caitp
Copy link
Contributor

caitp commented Feb 4, 2014

I think this is probably a WON'TFIX as I don't think it's a totally great idea to hide the exception if it happens, so I'm gonna close this.

@caitp caitp closed this as completed Feb 4, 2014
@caitp caitp reopened this Feb 4, 2014
@caitp
Copy link
Contributor

caitp commented Feb 4, 2014

re-opening this for now as Igor suggests it might be worth working around the bug.

@quantizor
Copy link
Author

It was definitely difficult to trace, so at least a note in the
documentation seems like a good idea.
On Feb 4, 2014 6:01 PM, "Caitlin Potter" [email protected] wrote:

re-opening this for now as Igor suggests it might be worth working around
the bug.


Reply to this email directly or view it on GitHubhttps://github.com//issues/6115#issuecomment-34118415
.

caitp added a commit to caitp/angular.js that referenced this issue Feb 4, 2014
WebKit added support for the json responseType value on 09/03/2013
https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are known to throw when
setting the value "json" as the response type. Other older browsers implementing the responseType.
Other browsers with infrequent update cycles may also be affected.

The json responseType value can be ignored if not supported, because JSON payloads are parsed on the
client-side regardless.

Closes angular#6115
@caitp caitp closed this as completed in 431bad0 Feb 4, 2014
caitp added a commit to caitp/angular.js that referenced this issue Feb 5, 2014
WebKit added support for the json responseType value on 09/03/2013
https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are known to throw when
setting the value "json" as the response type. Other older browsers implementing the responseType.
Other browsers with infrequent update cycles may also be affected.

The json responseType value can be ignored if not supported, because JSON payloads are parsed on the
client-side regardless.

Closes angular#6115
Closes angular#6122
caitp added a commit that referenced this issue Feb 5, 2014
WebKit added support for the json responseType value on 09/03/2013
https://bugs.webkit.org/show_bug.cgi?id=73648. Versions of Safari prior to 7 are known to throw when
setting the value "json" as the response type. Other older browsers implementing the responseType.
Other browsers with infrequent update cycles may also be affected.

The json responseType value can be ignored if not supported, because JSON payloads are parsed on the
client-side regardless.

Closes #6115
Closes #6122
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants