Unverified Commit 8e6205fe authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Handle thrown maps and rejects from fe server (#37743)

parent f887542a
...@@ -653,7 +653,7 @@ class ResidentCompiler { ...@@ -653,7 +653,7 @@ class ResidentCompiler {
if (!_compileRequestNeedsConfirmation) { if (!_compileRequestNeedsConfirmation) {
return Future<CompilerOutput>.value(null); return Future<CompilerOutput>.value(null);
} }
_stdoutHandler.reset(); _stdoutHandler.reset(expectSources: false);
_server.stdin.writeln('reject'); _server.stdin.writeln('reject');
printTrace('<- reject'); printTrace('<- reject');
_compileRequestNeedsConfirmation = false; _compileRequestNeedsConfirmation = false;
......
...@@ -540,12 +540,10 @@ abstract class ResidentRunner { ...@@ -540,12 +540,10 @@ abstract class ResidentRunner {
this.stayResident = true, this.stayResident = true,
this.hotMode = true, this.hotMode = true,
this.dillOutputPath, this.dillOutputPath,
}) { }) : mainPath = findMainDartFile(target),
_mainPath = findMainDartFile(target); projectRootPath = projectRootPath ?? fs.currentDirectory.path,
_projectRootPath = projectRootPath ?? fs.currentDirectory.path; packagesFilePath = packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath),
_packagesFilePath = assetBundle = AssetBundleFactory.instance.createBundle() {
packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath);
_assetBundle = AssetBundleFactory.instance.createBundle();
// TODO(jonahwilliams): this is transitionary logic to allow us to support // TODO(jonahwilliams): this is transitionary logic to allow us to support
// platforms that are not yet using flutter assemble. In the "new world", // platforms that are not yet using flutter assemble. In the "new world",
// builds are isolated based on a number of factors. Thus, we cannot assume // builds are isolated based on a number of factors. Thus, we cannot assume
...@@ -570,19 +568,15 @@ abstract class ResidentRunner { ...@@ -570,19 +568,15 @@ abstract class ResidentRunner {
final bool ipv6; final bool ipv6;
final Completer<int> _finished = Completer<int>(); final Completer<int> _finished = Completer<int>();
final String dillOutputPath; final String dillOutputPath;
final String packagesFilePath;
final String projectRootPath;
final String mainPath;
final AssetBundle assetBundle;
bool _exited = false; bool _exited = false;
bool hotMode ; bool hotMode ;
String _packagesFilePath;
String get packagesFilePath => _packagesFilePath;
String _projectRootPath;
String get projectRootPath => _projectRootPath;
String _mainPath;
String get mainPath => _mainPath;
String getReloadPath({ bool fullRestart }) => mainPath + (fullRestart ? '' : '.incremental') + '.dill'; String getReloadPath({ bool fullRestart }) => mainPath + (fullRestart ? '' : '.incremental') + '.dill';
AssetBundle _assetBundle;
AssetBundle get assetBundle => _assetBundle;
bool get isRunningDebug => debuggingOptions.buildInfo.isDebug; bool get isRunningDebug => debuggingOptions.buildInfo.isDebug;
bool get isRunningProfile => debuggingOptions.buildInfo.isProfile; bool get isRunningProfile => debuggingOptions.buildInfo.isProfile;
bool get isRunningRelease => debuggingOptions.buildInfo.isRelease; bool get isRunningRelease => debuggingOptions.buildInfo.isRelease;
......
...@@ -654,7 +654,7 @@ class HotRunner extends ResidentRunner { ...@@ -654,7 +654,7 @@ class HotRunner extends ResidentRunner {
for (FlutterDevice device in flutterDevices) { for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) { for (FlutterView view in device.views) {
if (view.uiIsolate == null) { if (view.uiIsolate == null) {
throw 'Application isolate not found'; return OperationResult(2, 'Application isolate not found', fatal: true);
} }
} }
} }
...@@ -762,7 +762,6 @@ class HotRunner extends ResidentRunner { ...@@ -762,7 +762,6 @@ class HotRunner extends ResidentRunner {
} }
// Record time it took for the VM to reload the sources. // Record time it took for the VM to reload the sources.
_addBenchmarkData('hotReloadVMReloadMilliseconds', vmReloadTimer.elapsed.inMilliseconds); _addBenchmarkData('hotReloadVMReloadMilliseconds', vmReloadTimer.elapsed.inMilliseconds);
final Stopwatch reassembleTimer = Stopwatch()..start(); final Stopwatch reassembleTimer = Stopwatch()..start();
// Reload the isolate. // Reload the isolate.
final List<Future<void>> allDevices = <Future<void>>[]; final List<Future<void>> allDevices = <Future<void>>[];
......
...@@ -1177,7 +1177,7 @@ class Isolate extends ServiceObjectOwner { ...@@ -1177,7 +1177,7 @@ class Isolate extends ServiceObjectOwner {
final Map<String, dynamic> response = await invokeRpcRaw('_reloadSources', params: arguments); final Map<String, dynamic> response = await invokeRpcRaw('_reloadSources', params: arguments);
return response; return response;
} on rpc.RpcException catch (e) { } on rpc.RpcException catch (e) {
return Future<Map<String, dynamic>>.error(<String, dynamic>{ return Future<Map<String, dynamic>>.value(<String, dynamic>{
'code': e.code, 'code': e.code,
'message': e.message, 'message': e.message,
'data': e.data, 'data': e.data,
......
...@@ -266,7 +266,6 @@ example:org-dartlang-app:/ ...@@ -266,7 +266,6 @@ example:org-dartlang-app:/
testUsingContext('compile and recompile', () async { testUsingContext('compile and recompile', () async {
final BufferLogger logger = context.get<Logger>(); final BufferLogger logger = context.get<Logger>();
final StreamController<List<int>> streamController = StreamController<List<int>>(); final StreamController<List<int>> streamController = StreamController<List<int>>();
when(mockFrontendServer.stdout) when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => streamController.stream); .thenAnswer((Invocation invocation) => streamController.stream);
...@@ -289,11 +288,10 @@ example:org-dartlang-app:/ ...@@ -289,11 +288,10 @@ example:org-dartlang-app:/
await _accept(streamController, generator, mockFrontendServerStdIn, '^accept\\n\$'); await _accept(streamController, generator, mockFrontendServerStdIn, '^accept\\n\$');
await _recompile(streamController, generator, mockFrontendServerStdIn, await _recompile(streamController, generator, mockFrontendServerStdIn,
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0\n'); 'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0\n');
// No sources returned from reject command.
await _reject(streamController, generator, mockFrontendServerStdIn, 'result abc\nabc\nabc\nabc', await _reject(streamController, generator, mockFrontendServerStdIn, 'result abc\nabc\n',
'^reject\\n\$'); '^reject\\n\$');
verifyNoMoreInteractions(mockFrontendServerStdIn); verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty); expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(logger.errorText, equals( expect(logger.errorText, equals(
...@@ -578,7 +576,6 @@ Future<void> _reject( ...@@ -578,7 +576,6 @@ Future<void> _reject(
expect(commands, matches(re)); expect(commands, matches(re));
mockFrontendServerStdIn._stdInWrites.clear(); mockFrontendServerStdIn._stdInWrites.clear();
} }
class MockProcessManager extends Mock implements ProcessManager {} class MockProcessManager extends Mock implements ProcessManager {}
class MockProcess extends Mock implements Process {} class MockProcess extends Mock implements Process {}
class MockStream extends Mock implements Stream<List<int>> {} class MockStream extends Mock implements Stream<List<int>> {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment