Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid JSON response decoding on iOS #30181

Closed
developius opened this issue Oct 15, 2020 · 3 comments
Closed

Invalid JSON response decoding on iOS #30181

developius opened this issue Oct 15, 2020 · 3 comments
Labels
Needs: Triage 🔍 Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@developius
Copy link

Description

Sending requests using apisauce/axios results in invalid JSON data on iOS.
The data appears incorrect with seemingly random characters present. It changes every response and I can't identify any kind of pattern.

This is happening both on physical devices and in the simulator. I cannot reproduce on Android.

Screen Shot 2020-10-15 at 3 03 11 PM

React Native version:

System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
    Memory: 689.28 MB / 24.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.19.0 - ~/.nvm/versions/node/v10.19.0/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.13.4 - ~/.nvm/versions/node/v10.19.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /Users/finnian/.rvm/gems/ruby-2.7.1/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.7, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5692245
    Xcode: 11.7/11E801a - /usr/bin/xcodebuild
  Languages:
    Java: 12.0.2 - /Users/finnian/.jenv/shims/javac
    Python: 2.7.10 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.3 => 0.63.3 (also happened on 0.61.5)
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Call an endpoint - I can't really identify why it's only some endpoints and not others. Maybe something to do with the response size - bigger responses seem to hit the error more often.

  1. const response = await this.apisauce.get('https://...')

Expected Results

I expect the response to be valid JSON.

Example of response headers:

{
  "access-control-expose-headers": "Request-Context",
  "cache-control": "no-cache",
  "content-length": "6634",
  "content-type": "application/vnd.api+json",
  "date": "Thu, 15 Oct 2020 02:14:51 GMT",
  "expires": "-1",
  "pragma": "no-cache",
  "request-context": "appId=cid-v1:<uuid>",
  "server": "Microsoft-IIS/10.0",
  "x-aspnet-version": "4.0.30319",
  "x-powered-by": "ASP.NET"
}

Snack, code example, screenshot, or link to a repository:

There are many other issues referencing very similar problems:
#29908 #29698 #29196 #27857

@developius
Copy link
Author

developius commented Oct 23, 2020

I think this (and maybe the other issues) might be related to this: axios/axios#2419
Looks like my response has a BOM character in it, which is throwing off JSON.parse in the axios library.
They have released the patch in v0.20.0 but there's an issue with that release.
We're using apisauce so a bit of dependency hell. I'll close this issue when I've verified their patch.

@jasonsaayman
Copy link

Hi,

Version 0.21.0 has been released 🎉 please use that and let us know if that solves your issue.

Thanks

@safaiyeh
Copy link
Contributor

Thanks for the issue @developius this seems to be an axios specific issue, closing as you can follow the progress there.

@facebook facebook locked as resolved and limited conversation to collaborators Oct 23, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants