fix: logging in bg

This commit is contained in:
Prateek Sunal
2025-06-16 13:02:52 +05:30
parent 25b96825cc
commit 60b040f54b

View File

@@ -126,20 +126,26 @@ Future<void> _homeWidgetSync([bool isBackground = false]) async {
}
Future<void> runBackgroundTask(String taskId, {String mode = 'normal'}) async {
try {
final cancellableOp = CancelableOperation.fromFuture(_runMinimally(taskId));
await _runWithLogs(
() async {
try {
final cancellableOp =
CancelableOperation.fromFuture(_runMinimally(taskId));
if (Platform.isIOS) {
_scheduleSuicide(
kBGTaskTimeout,
taskId,
cancellableOp,
);
}
await cancellableOp.valueOrCancellation();
} catch (e, s) {
_logger.severe("Error in background task", e, s);
}
if (Platform.isIOS) {
_scheduleSuicide(
kBGTaskTimeout,
taskId,
cancellableOp,
);
}
await cancellableOp.valueOrCancellation();
} catch (e, s) {
_logger.severe("Error in background task", e, s);
}
},
prefix: "[bg]",
);
}
Future<void> _runMinimally(String taskId) async {