diff --git a/packages/flutter_tools/lib/src/daemon.dart b/packages/flutter_tools/lib/src/daemon.dart index 898d2ee1b04c..1ea8908d7dca 100644 --- a/packages/flutter_tools/lib/src/daemon.dart +++ b/packages/flutter_tools/lib/src/daemon.dart @@ -340,7 +340,7 @@ class DaemonConnection { // This is an error response. _logger.printTrace('<- Error response received from daemon, id = $id'); final Object error = data['error']!; - final String stackTrace = data['stackTrace'] as String? ?? ''; + final String stackTrace = data['trace'] as String? ?? ''; _outgoingRequestCompleters.remove(id)?.completeError(error, StackTrace.fromString(stackTrace)); } else { _logger.printTrace('<- Response received from daemon, id = $id'); diff --git a/packages/flutter_tools/test/general.shard/daemon_test.dart b/packages/flutter_tools/test/general.shard/daemon_test.dart index 300c55485b09..577b7ec90e01 100644 --- a/packages/flutter_tools/test/general.shard/daemon_test.dart +++ b/packages/flutter_tools/test/general.shard/daemon_test.dart @@ -173,7 +173,18 @@ void main() { final String id = message.data['id']! as String; daemonStreams.inputs.add(DaemonMessage({'id': id, 'error': 'some_error', 'trace': 'stack trace'})); - expect(requestFuture, throwsA('some_error')); + + Object? gotError; + StackTrace? gotStackTrace; + try { + await requestFuture; + } on Object catch (error, stackTrace) { + gotError = error; + gotStackTrace = stackTrace; + } + + expect(gotError, 'some_error'); + expect(gotStackTrace.toString(), 'stack trace'); }); });