Automattic / Automattic/wordpress-rs

`.networkConnectionLost` is classified as `DeviceIsOfflineError` even when the server severed the connection

Open
#1,499 0 comments 0 reactions 0 assignees View on GitHub
Bug Error Handling Swift
Dominant language
Rust
Stars
36
Forks
5
Avg merge
17h 30m
Merged PRs (30d)
43

Description

> Split out from Automattic/wordpress-rs#1497 — *Swift executor URLSession error audit*. Section A — Converted to the wrong Rust error.
>
> File references are to `native/swift/Sources/wordpress-api/SafeRequestExecutor.swift` unless noted; `:NNN` line numbers were verified against `fix/converge-executor-error-classification`.

**Severity: high.** Apple documents -1005 as "a client or server connection was severed in the middle of an in-progress load" — it fires for server/proxy RSTs, load-balancer idle timeouts, and the notorious iOS stale keep-alive reuse case, with the device fully online. Apps show offline banners or queue for connectivity restoration when a plain retry would succeed. Swift is the only executor reporting offline for a server-side abort: reqwest maps the equivalent io `UnexpectedEof` to `HttpError { "The server terminated the connection unexpectedly" }` and never constructs `DeviceIsOfflineError`; Kotlin only claims offline after `NetworkAvailabilityProvider` confirms the network is down.

**Fix:** keep `.notConnectedToInternet` as `DeviceIsOfflineError`. For `.networkConnectionLost`, either (a) emit `HttpError` matching reqwest, or (b) — the faithful fix, since -1005 also fires on genuine mid-request connectivity drops — gate on a connectivity signal (`NWPathMonitor`, mirroring Kotlin's provider) and emit `DeviceIsOfflineError` only when the path is actually unsatisfied.

**Caveat:** `.networkConnectionLost` is listed as a Swift offline signal in the new `is_device_offline` rustdoc, so the contract text and the variant-coverage tests from 8aa3cf20 must move with the fix. The `waitsForConnectivity` caveat from Automattic/wordpress-rs#1491 doesn't help here — -1005 is reported for established connections.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in native/swift/Sources/wordpress-api/SafeRequestExecutor.swift at the .networkConnectionLost handling, then inspect the is_device_offline rustdoc and variant-coverage tests from 8aa3cf20. Compare the reqwest and Kotlin executor behavior and determine the appropriate connectivity signal. Done means server-side aborts no longer report offline while genuine offline cases retain DeviceIsOfflineError and the contract and tests are updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, rust, swift
Domain
api, networking, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.