Skip to content

Commit

Permalink
Get better stack trace on spurious error
Browse files Browse the repository at this point in the history
It appears that the agent is crashing and causing tests to fail
even the post-morten ones.
  • Loading branch information
CarlosNihelton committed Sep 6, 2023
1 parent 004d775 commit 5823e56
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import 'package:integration_test/integration_test.dart';
import 'package:p4w_ms_store/p4w_ms_store_method_channel.dart';
import 'package:p4w_ms_store/p4w_ms_store_platform_interface.dart';
import 'package:path/path.dart' as p;
// ignore: depend_on_referenced_packages
import 'package:stack_trace/stack_trace.dart' as stack_trace;
import 'package:ubuntu_service/ubuntu_service.dart';
import 'package:ubuntupro/constants.dart';
import 'package:ubuntupro/core/environment.dart';
Expand All @@ -20,6 +22,11 @@ import 'utils/build_agent.dart';

void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
FlutterError.demangleStackTrace = (stack) {
if (stack is stack_trace.Trace) return stack.vmTrace;
if (stack is stack_trace.Chain) return stack.toTrace().vmTrace;
return stack;
};

// A temporary directory mocking the $env:LocalAppData directory to sandbox our agent.
Directory? tmp;
Expand Down
9 changes: 8 additions & 1 deletion gui/packages/ubuntupro/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:agentapi/agentapi.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:grpc/grpc.dart';
import 'package:provider/provider.dart';
import 'package:ubuntu_service/ubuntu_service.dart';
import 'package:yaru/yaru.dart';
Expand Down Expand Up @@ -39,7 +40,13 @@ class Pro4WindowsApp extends StatelessWidget {
registerServiceInstance<AgentApiClient>(client);
final subscriptionInfo =
context.read<ValueNotifier<SubscriptionInfo>>();
subscriptionInfo.value = await client.subscriptionInfo();
// TODO: Remove this try-catch once the agent stop crashing due lack of MS Store access
try {
subscriptionInfo.value = await client.subscriptionInfo();
} on GrpcError catch (err) {
debugPrint('$err');
debugPrintStack(maxFrames: 20);
}
},
),
child: const StartupPage(nextRoute: Routes.subscriptionStatus),
Expand Down
1 change: 0 additions & 1 deletion gui/packages/ubuntupro/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:yaru_widgets/yaru_widgets.dart';

import 'app.dart';

Future<void> main() async {
Expand Down

0 comments on commit 5823e56

Please sign in to comment.