Skip to content

[Quick fix] iOS Release network requests not completing #722

Closed
@teodorciuraru

Description

@teodorciuraru

Dependencies

"react": "16.13.1",
"react-native": "0.63.4",
"rn-fetch-blob": "^0.12.0"

Problem

Network task fails to complete in Release mode (iOS) and seem to be blocking here, where self.task becomes nil and [nil resume] is called.

...
self.task = [session dataTaskWithRequest:req];
[self.task resume]; // self.task = nil

Workaround

Avoiding self.task makes the network requests work again, so we suspect a problem around it.

// self.task = [session dataTaskWithRequest:req];
// [self.task resume];
[[session dataTaskWithRequest:req] resume];

Proposal
Kindly select an option that works for both of us so a PR can be submitted:

  1. Avoid using the self.task property altogether. (probably not possible because it's used on cancelRequest)
  2. Should the task be declared weak? Declare self.task as strong.
  3. Postponing assignment:
NSURLSessionDataTask *task = [session dataTaskWithRequest:req];
[task resume];
self.task = task;

Work will be started immediately after response, because this issue is critical to us.

Edit: Submitted option 3 as a PR, cause it looks the least intrusive and would really help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions