diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index a9b27384750..b82e0aa45b9 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -144,10 +144,10 @@ class _Compiler { printTrace('Compiling ${request.path}'); compiler ??= createCompiler(); suppressOutput = false; - final String outputPath = await compiler.recompile(request.path, + final String outputPath = await handleTimeout(compiler.recompile(request.path, [request.path], outputPath: outputDill.path, - ); + ), request.path); // Check if the compiler produced the output. If it failed then // outputPath would be null. In this case pass null upwards to the @@ -180,13 +180,20 @@ class _Compiler { Future compile(String mainDart) { final Completer completer = new Completer(); compilerController.add(new _CompilationRequest(mainDart, completer)); - return completer.future; + return handleTimeout(completer.future, mainDart); } Future shutdown() async { await compiler.shutdown(); compiler = null; } + + static Future handleTimeout(Future value, String path) { + return value.timeout(const Duration(minutes: 5), onTimeout: () { + printError('Compilation of $path timed out after 5 minutes.'); + return null; + }); + } } class _FlutterPlatform extends PlatformPlugin {