Skip to content

iOS: Add early resolution and conditional streaming for GET requests#108

Draft
Copilot wants to merge 48 commits into
masterfrom
copilot/migrate-ios-implementation-to-alamofire
Draft

iOS: Add early resolution and conditional streaming for GET requests#108
Copilot wants to merge 48 commits into
masterfrom
copilot/migrate-ios-implementation-to-alamofire

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 29, 2026

Fix Parallel Request Cancellation Issue

Problem:

When running multiple requests in parallel, they were getting cancelled during session recreation. This happened because recreateSession() was cancelling all active requests.

Checklist:

  • Remove Request Cancellation:

    • Removed code that cancels active requests in recreateSession()
    • Active requests now continue on the old session until they complete
    • Keep old session alive for 30 seconds to allow requests to finish
  • Test:

    • Verify parallel requests work without cancellation

Changes:

Before:

  • recreateSession() cancelled all active requests when creating a new session
  • Old session was kept alive for only 0.5 seconds
  • Parallel requests would fail with cancellation errors

After:

  • recreateSession() does NOT cancel active requests
  • Active requests continue running on the old session
  • Old session is kept alive for 30 seconds to allow requests to complete
  • New requests use the new session with updated event monitors/interceptors
  • Parallel requests can now run without interference

⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Copilot AI changed the title [WIP] Migrate iOS implementation from AFNetworking to Alamofire Migrate iOS implementation from AFNetworking to Alamofire Mar 29, 2026
Copilot AI requested a review from farfromrefug March 29, 2026 16:13
Copilot AI changed the title Migrate iOS implementation from AFNetworking to Alamofire Improve iOS API with clean method names and memory-efficient streaming downloads Mar 29, 2026
Copilot AI and others added 2 commits March 29, 2026 17:05
Copilot AI changed the title Improve iOS API with clean method names and memory-efficient streaming downloads Align iOS response handling with Android: load data in memory for post-request processing Mar 29, 2026
Copilot AI changed the title Align iOS response handling with Android: load data in memory for post-request processing Implement streaming downloads for iOS GET requests using temp file approach Mar 29, 2026
Comment thread src/https/request.ios.ts
const contentLength = task.countOfBytesReceived;
const content = useLegacy ? new HttpsResponseLegacy(data, contentLength, opts.url) : getData(data);
const contentLength = response?.expectedContentLength ?? 0;
console.log('run done', contentLength);
Copy link
Copy Markdown
Contributor

@CatchABus CatchABus May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farfromrefug I believe we can remove this log.

@CatchABus
Copy link
Copy Markdown
Contributor

During build, an app prints the following warnings while using these changes:

/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1060:14: warning: non-final class 'EventMonitorWrapper' cannot conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
public class EventMonitorWrapper: NSObject, EventMonitor {
             ^
       final
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1063:16: warning: stored property 'requestDidResumeCallback' of 'Sendable'-conforming class 'EventMonitorWrapper' is mutable; this is an error in the Swift 6 language mode
    public var requestDidResumeCallback: ((URLRequest) -> Void)?
               ^
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1146:14: warning: non-final class 'RequestInterceptorWrapper' cannot conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
public class RequestInterceptorWrapper: NSObject, RequestInterceptor {
             ^
       final
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1149:16: warning: stored property 'adaptCallback' of 'Sendable'-conforming class 'RequestInterceptorWrapper' is mutable; this is an error in the Swift 6 language mode
    public var adaptCallback: ((URLRequest) -> URLRequest)?
               ^
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/SecurityPolicyWrapper.swift:6:14: warning: non-final class 'SecurityPolicyWrapper' cannot conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
public class SecurityPolicyWrapper: NSObject {
             ^
       final
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/SecurityPolicyWrapper.swift:8:17: warning: stored property 'pinnedCertificatesData' of 'Sendable'-conforming class 'SecurityPolicyWrapper' is mutable; this is an error in the Swift 6 language mode
    private var pinnedCertificatesData: [Data] = []
                ^
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1060:14: warning: non-final class 'EventMonitorWrapper' cannot conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
public class EventMonitorWrapper: NSObject, EventMonitor {
             ^
       final
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1063:16: warning: stored property 'requestDidResumeCallback' of 'Sendable'-conforming class 'EventMonitorWrapper' is mutable; this is an error in the Swift 6 language mode
    public var requestDidResumeCallback: ((URLRequest) -> Void)?
               ^
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1146:14: warning: non-final class 'RequestInterceptorWrapper' cannot conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
public class RequestInterceptorWrapper: NSObject, RequestInterceptor {
             ^
       final
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/AlamofireWrapper.swift:1149:16: warning: stored property 'adaptCallback' of 'Sendable'-conforming class 'RequestInterceptorWrapper' is mutable; this is an error in the Swift 6 language mode
    public var adaptCallback: ((URLRequest) -> URLRequest)?
               ^
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/SecurityPolicyWrapper.swift:6:14: warning: non-final class 'SecurityPolicyWrapper' cannot conform to the 'Sendable' protocol; this is an error in the Swift 6 language mode
public class SecurityPolicyWrapper: NSObject {
             ^
       final
/Users/mypc/Desktop/mydev/https/packages/https/platforms/ios/src/SecurityPolicyWrapper.swift:8:17: warning: stored property 'pinnedCertificatesData' of 'Sendable'-conforming class 'SecurityPolicyWrapper' is mutable; this is an error in the Swift 6 language mode
    private var pinnedCertificatesData: [Data] = []

@farfromrefug
Copy link
Copy Markdown
Member

@CatchABus Thank you will look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants