ionic-team / ionic-team/ion-ios-filetransfer

[Bug]: Each transfer leaks a URLSession — bulk downloads exhaust file descriptors

Open Beginner friendly
#22 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
0
Forks
7
Avg merge
44m
Merged PRs (30d)
1

Description

### Current Behavior

IONFLTRManager.downloadFile() / uploadFile() create a new URLSession per transfer:

```swift
let session = URLSession(configuration: .default, delegate: delegate, delegateQueue: nil)
session.downloadTask(with: request).resume()
```

The session is never invalidated. Per Apple's documentation, a URLSession strongly retains its delegate and its resources (including the keep-alive socket) until finishTasksAndInvalidate() / invalidateAndCancel() is called — otherwise it leaks until app exit. So every completed transfer leaks one session, one delegate, and one open socket / file descriptor.

### Expected Behavior

Invalidate the session in the final delegate callback, in both IONFLTRDownloadDelegate and IONFLTRUploadDelegate:

```swift
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: (any Error)?) {
defer { session.finishTasksAndInvalidate() }
// existing handling …
}
```

### Reproduction

.

### Screenshots / Media

_No response_

### Environment Details

```Shell
@capacitor/cli: 8.2.0
@capacitor/core: 8.2.0
@capacitor/android: 8.2.0
@capacitor/ios: 8.2.0

npm: 11.17.0
node: 26.4.0
pod: 1.16.2
```

### Versions Affected

1.0.3

### Platforms Affected

- [x] iOS
- [ ] Android
- [ ] Web

### Notes / Comments

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating IONFLTRManager.downloadFile() and uploadFile(), then inspect the final URLSession delegate callbacks in IONFLTRDownloadDelegate and IONFLTRUploadDelegate. Confirm that both transfer paths invalidate their sessions after completion and that completed bulk transfers no longer retain the session resources.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile-dev, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.