Repository navigation
Remove on-device network-type detection + release 0.1.0 - #5
Merged
Merged
Conversation
`NetworkInfoProvider` resolved `network.type` by bridging `NWPathMonitor.pathUpdateHandler` into a `CheckedContinuation`. That handler is not one-shot — it re-fires on every path change, and `monitor.cancel()` does not retract callbacks already dispatched to the monitor's queue. On a flapping/constrained network a second callback resumed the continuation twice, trapping the process with EXC_BREAKPOINT (SIGTRAP). This ran on every `/preload` (every chat message), so at scale it produced a steady, high-volume production crash concentrated on mobile users. The bug shipped in every release since 1.0.5 (Sept 2025). Rather than guard the continuation, remove the code path entirely: the ad server does not use `network.type` for ad selection (it only forwards it to DSPs as OpenRTB `connectiontype`), so there is nothing to keep. `type` is now always nil. `carrier` (already always nil on iOS 16+) and `detail` (cellular radio access tech, only meaningful alongside `type`) are dropped too. `userAgent` — the one field the server actually consumes (tracked in preload analytics) — is unchanged. A continuation that no longer exists cannot be double-resumed, so this eliminates the crash class rather than mitigating it. `type`/`carrier` stay in `NetworkInfo` as always-nil fields so the shape is stable and a value can be reintroduced later without a breaking change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
JakubMrozek
force-pushed
the
fix/network-monitor-double-resume
branch
from
July 2, 2026 13:00
9eef295 to
942118c
Compare
Removal of on-device network-type detection (NWPathMonitor double-resume crash). CHANGELOG entry + podspec version bump. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a hard crash (
EXC_BREAKPOINT/ SIGTRAP) reported from production (Polybuzz / PolySpeak —NetworkInfoProvider.observeNetworkType()in the crash log), by removing the crashing code path rather than guarding it.NetworkInfoProviderresolvednetwork.typeby bridgingNWPathMonitor.pathUpdateHandlerinto aCheckedContinuation:pathUpdateHandleris not one-shot — it re-fires on every path change, andmonitor.cancel()does not retract callbacks already dispatched to the monitor's (concurrent) queue. On a flapping/constrained network a second callback resumes the same continuation twice, which Swift's checked continuation turns into a fatal_assertionFailure. The reporter's crash frame isnw_path_is_constrained— a second path update carrying a constrained-status change.This ran inside
DeviceCollector.collectAsync()→ on every/preload(every chat message), so at scale it produced a steady, high-volume crash cluster concentrated on mobile users. It shipped in every release since 1.0.5 (Sept 2025) — not a v4 regression; v4 just relocated the code here.Why remove instead of guard
We confirmed against the ad server (
apps/ad-server) thatnetwork.typeis not used for ad selection, targeting, filtering, or pricing — validation has every network field optional, andtypeonly maps to OpenRTBdevice.connectiontypeforwarded to DSPs. So there is nothing to preserve. A continuation that no longer exists cannot be double-resumed → this eliminates the crash class instead of mitigating it.What changes
typedetection removed — the entireNWPathMonitorpath (observeNetworkType/currentNetworkType) is deleted.typeis now alwaysnil.carrieranddetaildropped —carrierwas already always nil on iOS 16+;detail(cellular RAT) was only meaningful gated ontype, which is gone. ThemapRadioAccesstable + CoreTelephony/Network imports go with them.userAgentunchanged — the one field the server actually consumes (tracked in thepreload_requestsanalytics table).type/carrierremain inNetworkInfoas always-nil fields so the shape stays stable and a value can be reintroduced later without a breaking change.Tests
Rewrote
NetworkInfoProviderTestsfor the simplified contract:type/carrieralways nil, bridge dict omits nil fields,userAgentsurfaced verbatim. Full suite green (166 tests) on the simulator; the network suite dropped from ~127s to ~31s (no moreNWPathMonitorwaits).Release
This PR includes the 0.1.0 release bump (CHANGELOG + podspec
s.version). Minor bump (0.0.5 → 0.1.0) because removingNetworkInfo.detailand makingtypeoptional is a breaking API change for direct consumers — flagged with a### Breakingnote. After merge: tag0.1.0andpod trunk pushperRELEASING.md.Follow-up (sequenced after this release)
sdk-swiftmust bump KontextKit (currently pinnedexact: "0.0.4") and adapt its consumer:NetworkInfo.typeis nowString?andNetworkInfo.detailis gone, soDeviceCollectorwon't compile until updated. To actually sendnetwork.type = nullon the wire, sdk-swift's ownNetworkDTO.typeshould become optional and forwardnil(today it would coerce to.other). Then release a newKontextSwiftSDK— that's the version Polybuzz updates to get the fix. Same for the RN/Flutter iOS halves.🤖 Generated with Claude Code