@@ -11,7 +11,6 @@ import 'package:celest_cli/src/utils/error.dart';
1111import 'package:celest_cli/src/utils/json.dart' ;
1212import 'package:celest_cli/src/utils/process.dart' ;
1313import 'package:celest_cli/src/utils/run.dart' ;
14- import 'package:collection/collection.dart' ;
1514import 'package:logging/logging.dart' ;
1615import 'package:meta/meta.dart' ;
1716import 'package:vm_service/vm_service.dart' ;
@@ -39,7 +38,6 @@ final class LocalApiRunner {
3938 final FrontendServerClient _client;
4039 final Process _localApiProcess;
4140 VmService ? _vmService;
42- late final String _vmIsolateId;
4341
4442 /// The WebSocket URI of the running Celest server.
4543 String get wsUri => _vmService! .wsUri! ;
@@ -53,7 +51,6 @@ final class LocalApiRunner {
5351 required String environmentId,
5452 required Map <String , String > configValues,
5553 required bool verbose,
56- List <String > additionalSources = const [],
5754 int ? port,
5855 @visibleForTesting Duration ? vmServiceTimeout,
5956 @visibleForTesting StringSink ? stdoutPipe,
@@ -269,7 +266,7 @@ final class LocalApiRunner {
269266 );
270267
271268 /// Waits for the main Isolate to be available, resume it, then return its ID.
272- static Future <String > _waitForIsolatesAndResume (VmService vmService) async {
269+ static Future <void > _waitForIsolatesAndResume (VmService vmService) async {
273270 var vm = await vmService.getVM ();
274271 var isolates = vm.isolates;
275272 final stopwatch = Stopwatch ()..start ();
@@ -288,14 +285,6 @@ final class LocalApiRunner {
288285 'VM started in ${stopwatch .elapsedMilliseconds }ms. '
289286 'Isolates: $isolates ' ,
290287 );
291- var isolateRef = isolates.firstWhereOrNull (
292- (isolate) => isolate.isSystemIsolate ?? false ,
293- );
294- isolateRef ?? = isolates.firstOrNull;
295- if (isolateRef == null ) {
296- throw StateError ('Could not determine main isolate ID.' );
297- }
298- return isolateRef.id! ;
299288 }
300289
301290 // Doesn't seem that we need pause-on-start anymore, but keeping code around
@@ -447,7 +436,7 @@ final class LocalApiRunner {
447436 });
448437 await _vmService! .streamListen (EventStreams .kLogging);
449438
450- _vmIsolateId = await _waitForIsolatesAndResume (_vmService! );
439+ await _waitForIsolatesAndResume (_vmService! );
451440
452441 await Future .any ([
453442 serverStartedCompleter.future,
@@ -480,7 +469,11 @@ final class LocalApiRunner {
480469 ]);
481470 final dillOutput = _client.expectOutput (result);
482471 _logger.fine ('Hot reloading local API with entrypoint: $dillOutput ' );
483- await _vmService! .reloadSources (_vmIsolateId, rootLibUri: dillOutput);
472+
473+ final isolates = await _vmService! .getVM ().then ((vm) => vm.isolates! );
474+ for (final isolate in isolates) {
475+ await _vmService! .reloadSources (isolate.id! , rootLibUri: dillOutput);
476+ }
484477 }
485478
486479 // Copied from `package:flutter_tools/src/run_hot.dart`
@@ -546,9 +539,10 @@ final class LocalApiRunner {
546539}
547540
548541final class CompilationException implements Exception {
549- CompilationException (this .message);
542+ CompilationException (this .message, [ this .compilerOutput = const []] );
550543
551544 final String message;
545+ final List <String > compilerOutput;
552546
553547 @override
554548 String toString () => message;
@@ -563,8 +557,10 @@ extension on FrontendServerClient {
563557 switch (result) {
564558 case CompileResult (errorCount: > 0 ):
565559 _logger.finest ('Error compiling local API' , result.debugResult);
560+ accept (); // Always accept so we can call `compile` again.
566561 throw CompilationException (
567562 'Error compiling local API: ${result .debugResult }' ,
563+ result.compilerOutputLines.toList (),
568564 );
569565 case CompileResult (: final dillOutput? ):
570566 accept ();
0 commit comments