Unverified Commit 618fac92 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Exit resident web runner on initial compilation failure (#41441)" (#41498)

parent ec3baa8d
...@@ -192,7 +192,9 @@ class ResidentWebRunner extends ResidentRunner { ...@@ -192,7 +192,9 @@ class ResidentWebRunner extends ResidentRunner {
_connectionResult = await _webFs.connect(debuggingOptions); _connectionResult = await _webFs.connect(debuggingOptions);
unawaited(_connectionResult.debugConnection.onDone.whenComplete(exit)); unawaited(_connectionResult.debugConnection.onDone.whenComplete(exit));
} }
} catch (err) { } catch (err, stackTrace) {
printError(err.toString());
printError(stackTrace.toString());
throwToolExit('Failed to build application for the web.'); throwToolExit('Failed to build application for the web.');
} finally { } finally {
buildStatus.stop(); buildStatus.stop();
......
...@@ -135,7 +135,7 @@ class WebFs { ...@@ -135,7 +135,7 @@ class WebFs {
_client.startBuild(); _client.startBuild();
await for (BuildResults results in _client.buildResults) { await for (BuildResults results in _client.buildResults) {
final BuildResult result = results.results.firstWhere((BuildResult result) { final BuildResult result = results.results.firstWhere((BuildResult result) {
return result.target == kBuildTargetName; return result.target == 'web';
}); });
if (result.status == BuildStatus.failed) { if (result.status == BuildStatus.failed) {
return false; return false;
...@@ -164,7 +164,6 @@ class WebFs { ...@@ -164,7 +164,6 @@ class WebFs {
final bool hasWebPlugins = findPlugins(flutterProject) final bool hasWebPlugins = findPlugins(flutterProject)
.any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey)); .any((Plugin p) => p.platforms.containsKey(WebPlugin.kConfigKey));
// Start the build daemon and run an initial build. // Start the build daemon and run an initial build.
final Completer<bool> inititalBuild = Completer<bool>();
final BuildDaemonClient client = await buildDaemonCreator final BuildDaemonClient client = await buildDaemonCreator
.startBuildDaemon(fs.currentDirectory.path, .startBuildDaemon(fs.currentDirectory.path,
release: buildInfo.isRelease, release: buildInfo.isRelease,
...@@ -179,17 +178,6 @@ class WebFs { ...@@ -179,17 +178,6 @@ class WebFs {
return results.results return results.results
.firstWhere((BuildResult result) => result.target == kBuildTargetName); .firstWhere((BuildResult result) => result.target == kBuildTargetName);
}); });
client.buildResults.listen((BuildResults buildResults) {
final BuildResult result = buildResults.results.firstWhere((BuildResult result) {
return result.target == kBuildTargetName;
});
if (result.status == BuildStatus.failed) {
inititalBuild.complete(false);
}
if (result.status == BuildStatus.succeeded) {
inititalBuild.complete(true);
}
});
final int daemonAssetPort = buildDaemonCreator.assetServerPort(fs.currentDirectory); final int daemonAssetPort = buildDaemonCreator.assetServerPort(fs.currentDirectory);
// Initialize the asset bundle. // Initialize the asset bundle.
...@@ -261,17 +249,13 @@ class WebFs { ...@@ -261,17 +249,13 @@ class WebFs {
cascade = cascade.add(assetServer.handle); cascade = cascade.add(assetServer.handle);
final HttpServer server = await httpMultiServerFactory(hostname ?? _kHostName, hostPort); final HttpServer server = await httpMultiServerFactory(hostname ?? _kHostName, hostPort);
shelf_io.serveRequests(server, cascade.handler); shelf_io.serveRequests(server, cascade.handler);
final WebFs webFS = WebFs( return WebFs(
client, client,
server, server,
dwds, dwds,
'http://$_kHostName:$hostPort/', 'http://$_kHostName:$hostPort/',
assetServer, assetServer,
); );
if (!await inititalBuild.future) {
throw Exception('Failed to compile for the web.');
}
return webFS;
} }
} }
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'package:build_daemon/client.dart'; import 'package:build_daemon/client.dart';
import 'package:build_daemon/data/build_status.dart'; import 'package:build_daemon/data/build_status.dart';
import 'package:built_collection/built_collection.dart';
import 'package:dwds/dwds.dart'; import 'package:dwds/dwds.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/os.dart';
...@@ -50,18 +49,7 @@ void main() { ...@@ -50,18 +49,7 @@ void main() {
return 1234; return 1234;
}); });
when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) { when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) {
return Stream<BuildResults>.fromFuture(Future<BuildResults>.value( return const Stream<BuildResults>.empty();
BuildResults((BuildResultsBuilder builder) {
builder.results = ListBuilder<BuildResult>(
<BuildResult>[
DefaultBuildResult((DefaultBuildResultBuilder builder) {
builder.target = 'web';
builder.status = BuildStatus.succeeded;
})
]
);
})
));
}); });
when(mockBuildDaemonCreator.assetServerPort(any)).thenReturn(4321); when(mockBuildDaemonCreator.assetServerPort(any)).thenReturn(4321);
testbed = Testbed( testbed = Testbed(
...@@ -153,34 +141,6 @@ void main() { ...@@ -153,34 +141,6 @@ void main() {
expect(lastPort, 1234); expect(lastPort, 1234);
expect(lastAddress, contains('foo')); expect(lastAddress, contains('foo'));
})); }));
test('Throws exception if build fails', () => testbed.run(() async {
when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) {
return Stream<BuildResults>.fromFuture(Future<BuildResults>.value(
BuildResults((BuildResultsBuilder builder) {
builder.results = ListBuilder<BuildResult>(
<BuildResult>[
DefaultBuildResult((DefaultBuildResultBuilder builder) {
builder.target = 'web';
builder.status = BuildStatus.failed;
})
]
);
})
));
});
final FlutterProject flutterProject = FlutterProject.current();
expect(WebFs.start(
skipDwds: false,
target: fs.path.join('lib', 'main.dart'),
buildInfo: BuildInfo.debug,
flutterProject: flutterProject,
initializePlatform: false,
hostname: 'foo',
port: '1234',
), throwsA(isInstanceOf<Exception>()));
}));
} }
class MockBuildDaemonCreator extends Mock implements BuildDaemonCreator {} class MockBuildDaemonCreator extends Mock implements BuildDaemonCreator {}
......
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