Skip to content

Agent Mesh

mobile: guard enrollment callbacks with mounted checks

Antonio Ojeabbd360183746
diff --git a/mobile/sam-node-app/lib/main.dart b/mobile/sam-node-app/lib/main.dart
index dcb5a907..c8e71b0b 100644
--- a/mobile/sam-node-app/lib/main.dart
+++ b/mobile/sam-node-app/lib/main.dart
@@ -781,10 +781,11 @@ class _NodeControlPageState extends State<NodeControlPage> {
final link = await Navigator.of(context).push<EnrollLink>(
MaterialPageRoute(builder: (_) => const ScanEnrollCodePage()),
);
- if (link != null) await _confirmAndEnroll(link);
+ if (link != null && mounted) await _confirmAndEnroll(link);
}
Future<void> _handleEnrollLink(String raw) async {
+ if (!mounted) return;
final link = parseEnrollLink(raw);
if (link == null) {
setState(() => _status = 'Ignored link: not a sam://enroll code');
@@ -836,7 +837,7 @@ class _NodeControlPageState extends State<NodeControlPage> {
],
),
);
- if (ok == true) await _enrollWithToken(link.server, link.token);
+ if (ok == true && mounted) await _enrollWithToken(link.server, link.token);
}
// Manual entry: the token field takes either a bare token (with the URL
diff --git a/mobile/sam-node-app/lib/scan_page.dart b/mobile/sam-node-app/lib/scan_page.dart
index 5bd71d90..1cf68318 100644
--- a/mobile/sam-node-app/lib/scan_page.dart
+++ b/mobile/sam-node-app/lib/scan_page.dart
@@ -35,6 +35,7 @@ class _ScanEnrollCodePageState extends State<ScanEnrollCodePage> {
continue;
}
_done = true;
+ if (!mounted) return;
Navigator.of(context).pop(link);
return;
}