bug(network): iOS getStatus() returns the last reachability callback value instead of reading current flags
Los mantenedores suelen responder en 29 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Java
- Estrellas
- 688
- Forks
- 692
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ionic-team/capacitor-plugins
-
triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ionic-team/capacitor-plugins#2616 ·
Los mantenedores suelen responder en 29 días
-
[@capacitor/app] iOS: 'Expression implicitly coerced from String? to Any' warning in getAppLanguageAbiertotriage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
ionic-team/capacitor-plugins#2604 ·
Los mantenedores suelen responder en 29 días
-
platform: ios
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
ionic-team/capacitor-plugins#2624 ·
Los mantenedores suelen responder en 29 días
-
bug(network): Android networkStatusChange re-queries the active network inside callbacks and fires on every capability changePosiblemente ocupada @kcjonson la tomó hace 9 días. Abiertoplatform: android
Dificultad 4/5 1-2 días Aptitud para principiantes 25/100
ionic-team/capacitor-plugins#2621 ·
Los mantenedores suelen responder en 29 días
-
platform: android platform: ios
Dificultad 5/5 Más de una semana Aptitud para principiantes 24/100
ionic-team/capacitor-plugins#2619 ·
Los mantenedores suelen responder en 29 días
Todos los issues de ionic-team/capacitor-plugins
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
intellij-elixir/intellij-elixir#4585 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
MetricsHub/metricshub-community#1474 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
adorsys/keycloak-config-cli#1742 ·
Los mantenedores suelen responder en 1 día
-
Booking links: POST /api/booking-links with a null element in "availabilityRules" throws NullPointerException and answers 500 instead of 400Posiblemente ocupada @chibenwa la tomó hoy. Abiertoai-driven-fuzzing bug claude Minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
linagora/twake-calendar-side-service#1322 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
PathnameExpander incorrectly interprets regex metacharacters in wildcard patternsPosiblemente ocupada @jiteshkhatri11 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
javapathfinder/jpf-core#662 · 1 comentario ·
Los mantenedores suelen responder en 1 día