question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetch only brings latest value of same-name headers on Android, works on iOS.

See original GitHub issue

This is a long standing bug reported here https://github.com/facebook/react-native/issues/18837. Unfortunately #18837 became stale but i can confirm the problem persists.

Environment

React Native Environment Info:

    System:
      OS: macOS Sierra 10.12.6
      CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
      Memory: 31.03 MB / 8.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.2, macOS 10.13, tvOS 11.2, watchOS 4.2
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.2, 26.0.3, 27.0.2, 27.0.3, 28.0.0
        System Images: android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.1 AI-173.4819257
      Xcode: 9.2/9C40b - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.57.8 => 0.57.8

Description

This is a long standing bug reported here https://github.com/facebook/react-native/issues/18837 and in different forms in many other places that i havent kept track of, will append later on with an edit.

The issue is that in the presence of multiple headers with the same name as is common with e.g Set-Cookie the android version of fetch will always only ever keep the latest cookie.

So in practice if one wants to get more than one cookies at a time from the response they received they cant do it. There is a workaround which also described on #18837 and essentially introduces the following changes to MainApplication.java:

ReadableNativeArray.setUseNativeAccessor(true);
ReadableNativeMap.setUseNativeAccessor(true);

However I am very uncertain as to what side-effects it might be causing elsewhere. Right now this is what im using but not feeling secure about it.

Reproducible Demo

Reproduction is identical to #18837 found here Reproduction can also be found in 18837 which i run and can confirm.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alubeckcommented, Mar 25, 2019

The truth @Return-1 ! I’m experiencing exactly the same, for me only the last Set-Cookie header gets properly used and read out on android - no problems on IOS.

This solution here https://github.com/facebook/react-native/issues/18837#issuecomment-398779994, is working for me, thanks Patrick. But it’s highly annoying that this doesn’t work 😦 … + maybe uncertain side effects this workaround comes with.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Only receives one cookie in fetch response on Android but not ...
When I send a POST fetch request to my website to login it all works on iOS. The fetch response set-cookie have all...
Read more >
Xcode 12 ProcessXCFramework fails to copy headers on build
I'm trying to build and run my app from Xcode 12 but the ProcessXCFramework step fails telling me that it could'n't copy the...
Read more >
<input>: The Input (Form Input) element - HTML
The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide...
Read more >
HTML Standard
Continuing the above example, a requirement stating that a particular attribute's value is constrained to being a valid integer emphatically does not imply ......
Read more >
Content Management API | Contentful
Takes an array of values and validates that the field value is in this array. Text, Symbol, Integer, Number, {"in": ["General", "iOS", "Android"]}....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found