From 4f3714e59549b06b026fbf49d23a5df9a83ce21b Mon Sep 17 00:00:00 2001 From: Sigmund Cherem Date: Tue, 24 May 2022 16:30:55 +0000 Subject: [PATCH] [dart2js] be resilient if we can't compute RAM usage. Under some configurations, we can't obtain an observatoryURI to compute the RAM utilization of dart2js. It appears this happens when building in product mode: "./tools/build.py -m product create_sdk". This changes the logic to return "N/A" when that happens. Change-Id: Ic8c9e89a09603558db3ac07ea696aed77f2eaca1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245781 Reviewed-by: Joshua Litt Commit-Queue: Sigmund Cherem --- pkg/compiler/lib/src/common/ram_usage.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/compiler/lib/src/common/ram_usage.dart b/pkg/compiler/lib/src/common/ram_usage.dart index 76c5c2d7e18..ade3c7b9bd0 100644 --- a/pkg/compiler/lib/src/common/ram_usage.dart +++ b/pkg/compiler/lib/src/common/ram_usage.dart @@ -18,10 +18,11 @@ import 'dart:developer'; import 'package:vm_service/vm_service_io.dart' as vm_service_io; -Future _currentHeapCapacity() async { +Future _currentHeapCapacity() async { final info = await Service.controlWebServer(enable: true, silenceOutput: true); - final observatoryUri = info.serverUri!; + final observatoryUri = info.serverUri; + if (observatoryUri == null) return null; final wsUri = 'ws://${observatoryUri.authority}${observatoryUri.path}ws'; final vmService = await vm_service_io.vmServiceConnectUri(wsUri); int sum = 0; @@ -35,5 +36,6 @@ Future _currentHeapCapacity() async { Future currentHeapCapacityInMb() async { final capacity = await _currentHeapCapacity(); + if (capacity == null) return "N/A MB"; return "${(capacity / (1024 * 1024)).toStringAsFixed(3)} MB"; }