Skip to content

fix(json): make async fetching portable on Linux - #1

Merged
rchatham merged 2 commits into
mainfrom
fix/linux-networking
Oct 5, 2026
Merged

rchatham merged 2 commits into
mainfrom
fix/linux-networking

Conversation

@rchatham

@rchatham rchatham commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Import FoundationNetworking conditionally for JSON.fetch's URLSession, URLRequest and HTTPURLResponse types on Linux; Apple behavior is unchanged.
  • Add five network-free fetch tests covering URL and custom POST request overloads, parsed HTTP error bodies, invalid JSON and transport error propagation. Each test owns an ephemeral session; the mock has no shared mutable state.
  • Linux Swift 5.10 also lacks the async URLSession.data(for:) API. Provide a cancellation-aware callback bridge only for Linux compilers older than Swift 6; Apple and Swift 6 use the unchanged native API. Add a preflight cancellation test scoped to that shim.

Verification

  • Reproduced the unmodified main revision's Linux core build failure in swift:6.0-jammy on the existing dev server: URLSession unavailable/missing networking types; exit 1.
  • Final full suites: 451 tests, zero failures on Linux Swift 5.10; 450 tests, zero failures on Linux Swift 6.0.3 and macOS (baseline 445). Linux core build also passes.
  • The first PR iteration's Swift 5.10 CI failure exposed the missing async API and led to the compatibility bridge. A cancellation assertion initially applied to all platforms was narrowed to the shim: native Swift 6 Linux may complete an immediate mock response before cancellation. No stronger native cancellation contract or production behavior change is claimed.
  • Code review completed. No live API requests, credentials, releases or deployments.

Consumers

Unblocks LangTools PR rchatham/LangTools.swift#71. Consumers will use an immutable commit pin until a separately approved JSON release is available. No automatic merges or releases.

Final upstream CI matrix passed all four macOS/Linux Swift 5.10/6.0 jobs.

@rchatham rchatham changed the title fix(json): support FoundationNetworking on Linux fix(json): make async fetching portable on Linux Oct 5, 2026
@rchatham
rchatham merged commit 498270c into main Oct 5, 2026
4 checks passed
@rchatham
rchatham deleted the fix/linux-networking branch October 6, 2026 02:31
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.

1 participant