bug(network): iOS getStatus() returns the last reachability callback value instead of reading current flags
I maintainer di solito rispondono entro 29 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start with NetworkPlugin.swift lines 29–32, then follow Network.currentStatus() into Network.swift and Reachability.swift lines 95–105 to see how flags are read and updated. Reproduce by calling Network.getStatus() immediately after changing network state and compare it with the next networkStatusChange event. Done means getStatus() reads current flags when called; an open linked pull request (#2622) is already addressing this issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
Plugin(s)
@capacitor/network 8.0.1 (same code on main at 87c0bb8 and in 9.0.0-alpha.2)
Capacitor Version
@capacitor/core: 8.5.3
@capacitor/ios: 8.5.3
@capacitor/network: 8.0.1
Xcode 27.1, iOS SDK 27.1
Platform(s)
iOS
Current Behavior
Network.getStatus() doesn't take a reading. It returns whatever the last SCNetworkReachability callback stored.
getStatus (NetworkPlugin.swift:29-32) calls Network.currentStatus() (Network.swift:31-33), which reads Reachability.connection (Reachability.swift:95-105):
public var connection: Connection {
if flags == nil {
try? setReachabilityFlags()
}
switch flags?.connection {
Flags are only read synchronously when they're nil (first call, or the initial check in startNotifier). After that, flags is only updated by the reachability callback, so getStatus() answers with the state as of the last callback. Called right after a network change, before that callback has landed on the reachability queue, it returns the previous state.
Expected Behavior
getStatus() reads the current flags when it is called.
Code Reproduction
No sample app needed beyond the plugin's own example:
import { Network } from '@capacitor/network';
Network.addListener('networkStatusChange', s => console.log('event', Date.now(), s));
- Run on a device on Wi-Fi.
- Turn Wi-Fi off in Control Center (with cellular off or available).
- Immediately call
await Network.getStatus()(e.g. from a button, or in a tight loop logging every few ms) and compare it to the nextnetworkStatusChangeevent. Until the event arrives,getStatus()keeps returning the previousconnectionType/connected, because nothing re-reads the flags.
Other Technical Details
- This is only about
getStatus()freshness. A PR follows that re-reads the flags synchronously ingetStatus()and keeps the existing SCNetworkReachability implementation. - Moving to
NWPathMonitoris a bigger change and overlaps #2555, which already adds anNWPathMonitor. Captive-portal / internet-reachability detection is #2564. Neither changes howgetStatus()reads the cached flags (#2564'scurrentConnection()still readsreachability.connection).
Additional Context
Older reports with related symptoms, closed during backlog cleanup without a fix: #40 (one commenter there notes getStatus() being out of sync with the actual state).
- Lingua principale
- Java
- Stelle
- 688
- Fork
- 692
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ionic-team/capacitor-plugins
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ionic-team/capacitor-plugins#2616 ·
I maintainer di solito rispondono entro 29 giorni
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageApertatriage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
ionic-team/capacitor-plugins#2604 ·
I maintainer di solito rispondono entro 29 giorni
-
platform: ios
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
ionic-team/capacitor-plugins#2624 ·
I maintainer di solito rispondono entro 29 giorni
-
bug(network): Android networkStatusChange re-queries the active network inside callbacks and fires on every capability changeForse già presa @kcjonson l’ha presa 12 giorni fa. Apertaplatform: android
Difficoltà 4/5 1-2 giorni Idoneità per principianti 25/100
ionic-team/capacitor-plugins#2621 ·
I maintainer di solito rispondono entro 29 giorni
-
platform: android platform: ios
Difficoltà 5/5 Più di una settimana Idoneità per principianti 24/100
ionic-team/capacitor-plugins#2619 ·
I maintainer di solito rispondono entro 29 giorni
Tutte le issue di ionic-team/capacitor-plugins
Issue simili
-
status:pending type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
EngineHub/WorldGuard#2329 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Dans-Plugins/Medieval-Roleplay-Engine#396 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 6 giorni
-
type: dependency-upgrade
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
spring-projects/spring-session#4156 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
quarkiverse/quarkus-langchain4j#3127 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno