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

iOS 10 fetch crashes #11133

Closed
juldiadia opened this issue Nov 25, 2016 · 7 comments
Closed

iOS 10 fetch crashes #11133

juldiadia opened this issue Nov 25, 2016 · 7 comments
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@juldiadia
Copy link

Description

fetch POST request are randomly crashing in iOS 10.
It throws a Network request failed.

Same code is working well in Android and iOS < 10.

Reproduction

Execute consecutive but different request to the same server using fetch like in the example below.

const fetching = () => {
            fetch('http://SERVER_URL/get', {
                method: 'GET'
             })
            .then((res1) => {
                fetch('http://SERVER_URL/post', {
                    method: 'POST',
                    body: JSON.stringify({ params: [
                        'element1',
                        'element2',
                        'element3',
                        'element4'
                    ] }) }
                )
                    .then((res2) => {
                        console.log('OK');
                    })
                    .catch((err2) => console.log('NOT OK')); 
            });
            
        };

        setInterval(fetching, 10);

Output in iOS 10

2016-11-25 14:22:05.810 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:05.814 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.064 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.135 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.136 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.595 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.597 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.763 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.766 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.769 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.778 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.795 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.806 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.822 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.833 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.844 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.864 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.879 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.897 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.910 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.930 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.942 [info][tid:com.facebook.react.JavaScript] NOT OK
2016-11-25 14:22:06.965 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:22:06.974 [info][tid:com.facebook.react.JavaScript] NOT OK

Output in iOS 9

2016-11-25 14:27:13.209 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.506 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.513 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.527 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.610 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.621 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.637 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.647 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.649 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.655 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.666 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.690 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.712 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.719 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.726 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.736 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.753 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.767 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.789 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.802 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.819 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.840 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.850 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.870 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.887 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.902 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.919 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.940 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.954 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.965 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:13.989 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.004 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.022 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.042 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.054 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.070 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.086 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.101 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.122 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.136 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.155 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.169 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.188 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.202 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.221 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.232 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.295 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.311 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.318 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.333 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.356 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.374 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.386 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.407 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.418 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.436 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.455 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.469 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.493 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.502 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.518 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.538 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.553 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.570 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.585 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.606 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.626 [info][tid:com.facebook.react.JavaScript] OK
2016-11-25 14:27:14.643 [info][tid:com.facebook.react.JavaScript] OK

Solution

It seems to be related to problems with iOS 10 NSURLSession according to this http://stackoverflow.com/questions/39346231/resume-nsurlsession-on-ios10/39347461

Additional Information

  • React Native version: 0.32 and 0.38 tested
  • Platform: [iOS]
  • Operating System: [MacOS]
@mkonicek
Copy link
Contributor

Thanks for reporting! What is the err2 when 'NOT OK' is printed?

@max-mykhailenko
Copy link

@juldiadia I have the same issue. Can you help with solution?

@emadicio
Copy link

emadicio commented Dec 20, 2016

Same issue!

I'm sure this issue is related exclusively to RN because I have two exact copies of the same app, on running on RN 0.33 and the other one running on RN 0.39 and second app keeps failing network requests.

@emadicio
Copy link

@max-mykhailenko @juldiadia Maybe it's not related, but this fixed it for me #11342

@max-mykhailenko
Copy link

@Ethan37 Thanks, I'll look to it

@max-mykhailenko
Copy link

@juldiadia can you create pull request with fix from stack overflow?

@shergin shergin added the Platform: iOS iOS applications. label Mar 16, 2017
@hramos
Copy link
Contributor

hramos commented Jul 20, 2017

Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally!

If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:

  • Does the issue still reproduce on the latest release candidate? Post a comment with the version you tested.
  • If so, is there any information missing from the bug report? Post a comment with all the information required by the issue template.
  • Is there a pull request that addresses this issue? Post a comment with the PR number so we can follow up.

If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution.

@hramos hramos added the Icebox label Jul 20, 2017
@hramos hramos closed this as completed Jul 20, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Jul 20, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants