fix: handle DBusServiceUnknownException on Linux without NetworkManager
This commit is contained in:
@@ -198,6 +198,11 @@ FutureOr<SentryEvent?> _beforeSend(SentryEvent event, Hint _) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Drop DBusServiceUnknownException from Linux without NetworkManager
|
||||
if (exceptions != null && exceptions.any((e) => e.type == 'DBusServiceUnknownException')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Scrub Plex tokens and server URLs from exception messages
|
||||
if (exceptions != null) {
|
||||
exceptions = exceptions.map((e) {
|
||||
|
||||
@@ -48,9 +48,9 @@ class OfflineModeProvider extends ChangeNotifier {
|
||||
// Check initial connectivity
|
||||
await _updateConnectionFlags();
|
||||
|
||||
// Monitor connectivity changes — wrapped in try-catch because
|
||||
// connectivity_plus can throw synchronously on Windows (NetworkManager::StartListen)
|
||||
try {
|
||||
// Monitor connectivity changes — runZonedGuarded catches async errors from
|
||||
// connectivity_plus (e.g. DBusServiceUnknownException on Linux without NetworkManager)
|
||||
runZonedGuarded(() {
|
||||
_connectivitySubscription = Connectivity().onConnectivityChanged.listen(
|
||||
(results) {
|
||||
final wasOffline = isOffline;
|
||||
@@ -61,14 +61,13 @@ class OfflineModeProvider extends ChangeNotifier {
|
||||
}
|
||||
},
|
||||
onError: (e) {
|
||||
// Assume network available on stream error
|
||||
_hasNetworkConnection = true;
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
// Assume network available if stream activation fails
|
||||
}, (error, stack) {
|
||||
// connectivity_plus throws DBusServiceUnknownException on Linux without NetworkManager
|
||||
_hasNetworkConnection = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Monitor server status from MultiServerManager
|
||||
_serverStatusSubscription = _serverManager.statusStream.listen((statusMap) {
|
||||
|
||||
@@ -316,33 +316,37 @@ class MultiServerManager {
|
||||
}
|
||||
|
||||
appLogger.i('Starting network monitoring for all servers');
|
||||
final connectivity = Connectivity();
|
||||
_connectivitySubscription = connectivity.onConnectivityChanged.listen(
|
||||
(results) {
|
||||
final status = results.isNotEmpty ? results.first : ConnectivityResult.none;
|
||||
runZonedGuarded(() {
|
||||
final connectivity = Connectivity();
|
||||
_connectivitySubscription = connectivity.onConnectivityChanged.listen(
|
||||
(results) {
|
||||
final status = results.isNotEmpty ? results.first : ConnectivityResult.none;
|
||||
|
||||
if (status == ConnectivityResult.none) {
|
||||
appLogger.w('Connectivity lost, pausing optimization until network returns');
|
||||
return;
|
||||
}
|
||||
if (status == ConnectivityResult.none) {
|
||||
appLogger.w('Connectivity lost, pausing optimization until network returns');
|
||||
return;
|
||||
}
|
||||
|
||||
appLogger.d(
|
||||
'Connectivity change detected, re-optimizing all servers',
|
||||
error: {
|
||||
'status': status.name,
|
||||
'interfaces': results.map((r) => r.name).toList(),
|
||||
'serverCount': _servers.length,
|
||||
},
|
||||
);
|
||||
appLogger.d(
|
||||
'Connectivity change detected, re-optimizing all servers',
|
||||
error: {
|
||||
'status': status.name,
|
||||
'interfaces': results.map((r) => r.name).toList(),
|
||||
'serverCount': _servers.length,
|
||||
},
|
||||
);
|
||||
|
||||
// Re-optimize all servers and re-probe offline ones
|
||||
_reoptimizeAllServers(reason: 'connectivity:${status.name}');
|
||||
checkServerHealth();
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
appLogger.w('Connectivity listener error', error: error, stackTrace: stackTrace);
|
||||
},
|
||||
);
|
||||
// Re-optimize all servers and re-probe offline ones
|
||||
_reoptimizeAllServers(reason: 'connectivity:${status.name}');
|
||||
checkServerHealth();
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
appLogger.w('Connectivity listener error', error: error, stackTrace: stackTrace);
|
||||
},
|
||||
);
|
||||
}, (error, stack) {
|
||||
appLogger.w('Connectivity monitoring unavailable', error: error);
|
||||
});
|
||||
}
|
||||
|
||||
/// Stop monitoring network connectivity
|
||||
|
||||
Reference in New Issue
Block a user