Skip to content

Invalid JSON response decoding on iOS #30181

@developius

Description

@developius

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions