diff --git a/app/bin/diet_guard_desktop.dart b/app/bin/diet_guard_desktop.dart index 3b1a2ed..d4a2f61 100644 --- a/app/bin/diet_guard_desktop.dart +++ b/app/bin/diet_guard_desktop.dart @@ -104,14 +104,17 @@ Future _provisionSyncAccount(String home, int port) async { '--disable-gpu', '--user-data-dir=${_profileDir(home)}', '--virtual-time-budget=45000', - '--dump-dom', + // Surface the page's own log() output, so a failure inside the app + // is visible in the terminal that started the provisioning run. + '--enable-logging=stderr', 'http://localhost:$port', ]); - final code = await process.exitCode; - if (code != 0) { - stderr.writeln('Headless provisioning run exited with $code.'); - return false; - } + // No --virtual-time-budget: it makes Chrome SIGKILL itself when the budget + // expires, which both reads as a failure and can cut the sync short. Give + // the page a real window of wall-clock time instead, then close it. + await Future.delayed(const Duration(seconds: 40)); + process.kill(); + await process.exitCode; stdout.writeln( 'Provisioning run complete. Launch normally to confirm it is connected.', ); diff --git a/app/lib/screens/log_meal_screen.dart b/app/lib/screens/log_meal_screen.dart index 8a42575..74ac5e6 100644 --- a/app/lib/screens/log_meal_screen.dart +++ b/app/lib/screens/log_meal_screen.dart @@ -2,8 +2,9 @@ /// screen: "I can open the diet app on my phone and fill meal I ate." library; -import 'dart:async'; +import 'dart:async'; +import 'dart:developer'; import 'package:crdt_sync/crdt_sync.dart'; import 'package:diet_guard_app/models/food_entry.dart'; import 'package:diet_guard_app/models/food_suggestion.dart'; @@ -136,9 +137,17 @@ class _LogMealScreenState extends State } if (!mounted) return; await _refreshSlots(); - } on Exception { - // Best-effort: ignore (offline, transient GitHub errors, unmocked - // platform channels under test, etc.). + } on Object catch (error, stackTrace) { + // Best-effort, but never silent: this swallowed the reason a desktop + // install could not publish at all, which looked identical to "nothing + // to sync". Offline and unmocked-platform-channel-under-test both land + // here too, so it stays non-fatal -- it just says why now. + log( + 'diet_guard auto-sync failed', + level: 1000, + error: error, + stackTrace: stackTrace, + ); } finally { _autoSyncing = false; }