Skip to content

Conversation

@realrajaryan
Copy link
Contributor

@realrajaryan realrajaryan commented Nov 3, 2025

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Currently, when FileDownloader.downloadFile() encounters an error during client.execute() (e.g., XPC connection interruption or network timeout), the HTTPClient instance is deallocated without calling shutdown(), resulting in a crash:
AsyncHTTPClient/HTTPClient.swift:187: Fatal error: Client not shut down before the deinit.

This caused a control flow issue when attempting to download the default kernel during container system start and, under certain conditions (e.g., network latency), encountering the timeout error HTTPClientError.connectTimeout.

To address this, client.execute() is now wrapped in a do/catch to ensure shutdown() is always called on both success and error paths. Also I've added an explicit timeout configuration (30s connect, no read timeout) to better accommodate large file downloads.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@realrajaryan realrajaryan requested a review from jglogan November 3, 2025 21:10
@dcantah dcantah merged commit e1e016b into apple:main Nov 3, 2025
2 checks passed
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