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 {
if (!_compileRequestNeedsConfirmation) {
return Future<CompilerOutput>.value(null);
}
_stdoutHandler.reset();
_stdoutHandler.reset(expectSources: false);
_server.stdin.writeln('reject');
printTrace('<- reject');
_compileRequestNeedsConfirmation = false;
......
......@@ -540,12 +540,10 @@ abstract class ResidentRunner {
this.stayResident = true,
this.hotMode = true,
this.dillOutputPath,
}) {
_mainPath = findMainDartFile(target);
_projectRootPath = projectRootPath ?? fs.currentDirectory.path;
_packagesFilePath =
packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath);
_assetBundle = AssetBundleFactory.instance.createBundle();
}) : mainPath = findMainDartFile(target),
projectRootPath = projectRootPath ?? fs.currentDirectory.path,
packagesFilePath = packagesFilePath ?? fs.path.absolute(PackageMap.globalPackagesPath),
assetBundle = AssetBundleFactory.instance.createBundle() {
// TODO(jonahwilliams): this is transitionary logic to allow us to support
// 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
......@@ -570,19 +568,15 @@ abstract class ResidentRunner {
final bool ipv6;
final Completer<int> _finished = Completer<int>();
final String dillOutputPath;
final String packagesFilePath;
final String projectRootPath;
final String mainPath;
final AssetBundle assetBundle;
bool _exited = false;
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';
AssetBundle _assetBundle;
AssetBundle get assetBundle => _assetBundle;
bool get isRunningDebug => debuggingOptions.buildInfo.isDebug;
bool get isRunningProfile => debuggingOptions.buildInfo.isProfile;
bool get isRunningRelease => debuggingOptions.buildInfo.isRelease;
......
......@@ -654,7 +654,7 @@ class HotRunner extends ResidentRunner {
for (FlutterDevice device in flutterDevices) {
for (FlutterView view in device.views) {
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 {
}
// Record time it took for the VM to reload the sources.
_addBenchmarkData('hotReloadVMReloadMilliseconds', vmReloadTimer.elapsed.inMilliseconds);
final Stopwatch reassembleTimer = Stopwatch()..start();
// Reload the isolate.
final List<Future<void>> allDevices = <Future<void>>[];
......
......@@ -1177,7 +1177,7 @@ class Isolate extends ServiceObjectOwner {
final Map<String, dynamic> response = await invokeRpcRaw('_reloadSources', params: arguments);
return response;
} on rpc.RpcException catch (e) {
return Future<Map<String, dynamic>>.error(<String, dynamic>{
return Future<Map<String, dynamic>>.value(<String, dynamic>{
'code': e.code,
'message': e.message,
'data': e.data,
......
......@@ -266,7 +266,6 @@ example:org-dartlang-app:/
testUsingContext('compile and recompile', () async {
final BufferLogger logger = context.get<Logger>();
final StreamController<List<int>> streamController = StreamController<List<int>>();
when(mockFrontendServer.stdout)
.thenAnswer((Invocation invocation) => streamController.stream);
......@@ -289,11 +288,10 @@ example:org-dartlang-app:/
await _accept(streamController, generator, mockFrontendServerStdIn, '^accept\\n\$');
await _recompile(streamController, generator, mockFrontendServerStdIn,
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0\n');
await _reject(streamController, generator, mockFrontendServerStdIn, 'result abc\nabc\nabc\nabc',
'^reject\\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\n',
'^reject\\n\$');
verifyNoMoreInteractions(mockFrontendServerStdIn);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
expect(logger.errorText, equals(
......@@ -578,7 +576,6 @@ Future<void> _reject(
expect(commands, matches(re));
mockFrontendServerStdIn._stdInWrites.clear();
}
class MockProcessManager extends Mock implements ProcessManager {}
class MockProcess extends Mock implements Process {}
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