@@ -27,14 +27,22 @@ class _Compiler {
27
27
28
28
/// Sends [request] on [_sendPort] and returns the next event from the
29
29
/// response stream.
30
- Future <Map <String , Object >> _send (Map <String , Object > request) async {
30
+ Future <Map <String , dynamic >> _send (Map <String , Object > request) async {
31
31
_sendPort.send (request);
32
- return await _responseQueue.hasNext
33
- ? Map <String , Object >.from (await _responseQueue.next)
34
- : {
35
- 'succeeded' : false ,
36
- 'errors' : ['compilation service response stream closed' ],
37
- };
32
+ if (! await _responseQueue.hasNext) {
33
+ return {
34
+ 'succeeded' : false ,
35
+ 'errors' : ['compilation worker response stream closed' ],
36
+ };
37
+ }
38
+ final response = await _responseQueue.next;
39
+ if (response is ! Map <String , dynamic >) {
40
+ return {
41
+ 'succeeded' : false ,
42
+ 'errors' : ['compilation worker returned invalid response: $response ' ],
43
+ };
44
+ }
45
+ return response;
38
46
}
39
47
40
48
/// Starts expression compilation service.
@@ -46,11 +54,11 @@ class _Compiler {
46
54
/// expression compilation (summaries, libraries spec, compiler worker
47
55
/// snapshot).
48
56
///
49
- /// [soundNullSafety] indiciates if the compioler should support sound null
50
- /// safety.
57
+ /// [soundNullSafety] indicates if the compiler should support sound
58
+ /// null safety.
51
59
///
52
60
/// Performs handshake with the isolate running expression compiler
53
- /// worker to estabish communication via send/receive ports, returns
61
+ /// worker to establish communication via send/receive ports, returns
54
62
/// the service after the communication is established.
55
63
///
56
64
/// Users need to stop the service by calling [stop] .
@@ -131,9 +139,12 @@ class _Compiler {
131
139
if (result) {
132
140
_logger.info ('Updated dependencies.' );
133
141
} else {
134
- final e = response['exception' ];
135
- final s = response['stackTrace' ];
136
- _logger.severe ('Failed to update dependencies: $e :$s ' );
142
+ final errors = response['errors' ];
143
+ final exception = response['exception' ];
144
+ final s = response['stackTrace' ] as String ? ;
145
+ final stackTrace = s == null ? null : StackTrace .fromString (s);
146
+ _logger.severe (
147
+ 'Failed to update dependencies: $errors ' , exception, stackTrace);
137
148
}
138
149
updateCompleter.complete ();
139
150
return result;
0 commit comments