File tree Expand file tree Collapse file tree 3 files changed +13
-20
lines changed Expand file tree Collapse file tree 3 files changed +13
-20
lines changed Original file line number Diff line number Diff line change 33// https://opensource.org/licenses/MIT.
44
55import 'dart:convert' ;
6+ import 'dart:io' if (dart.library.js) 'js/io.dart' ;
67import 'dart:isolate' if (dart.library.js) 'js/isolate.dart' ;
78import 'dart:typed_data' ;
89
@@ -408,16 +409,16 @@ final class CompilationDispatcher {
408409 message.writeToCodedBufferWriter (protobufWriter);
409410
410411 // Add one additional byte to the beginning to indicate whether or not the
411- // compilation has finished (1) or encountered a fatal error (2 ), so the
412- // [IsolateDispatcher] knows whether to treat this isolate as inactive or
413- // close out entirely.
412+ // compilation has finished (1) or encountered a fatal error (exitCode ), so
413+ // the [IsolateDispatcher] knows whether to treat this isolate as inactive
414+ // or close out entirely.
414415 var packet = Uint8List (
415416 1 + _compilationIdVarint.length + protobufWriter.lengthInBytes,
416417 );
417418 packet[0 ] = switch (message.whichMessage ()) {
418419 OutboundMessage_Message .compileResponse => 1 ,
419- OutboundMessage_Message .error => 2 ,
420- _ => 0 ,
420+ OutboundMessage_Message .error => exitCode ,
421+ _ => 0
421422 };
422423 packet.setAll (1 , _compilationIdVarint);
423424 protobufWriter.writeTo (packet, 1 + _compilationIdVarint.length);
Original file line number Diff line number Diff line change @@ -141,11 +141,11 @@ class IsolateDispatcher {
141141 var fullBuffer = message as Uint8List ;
142142
143143 // The first byte of messages from isolates indicates whether the entire
144- // compilation is finished (1) or if it encountered an error (2). Sending
145- // this as part of the message buffer rather than a separate message
146- // avoids a race condition where the host might send a new compilation
147- // request with the same ID as one that just finished before the
148- // [IsolateDispatcher] receives word that the isolate with that ID is
144+ // compilation is finished (1) or if it encountered an error (exitCode).
145+ // Sending this as part of the message buffer rather than a separate
146+ // message avoids a race condition where the host might send a new
147+ // compilation request with the same ID as one that just finished before
148+ // the [IsolateDispatcher] receives word that the isolate with that ID is
149149 // done. See sass/dart-sass#2004.
150150 var category = fullBuffer[0 ];
151151 var packet = Uint8List .sublistView (fullBuffer, 1 );
@@ -159,8 +159,9 @@ class IsolateDispatcher {
159159 _inactiveIsolates.add (isolate);
160160 resource.release ();
161161 _channel.sink.add (packet);
162- case 2 :
162+ default :
163163 _channel.sink.add (packet);
164+ exitCode = category;
164165 if (_gracefulShutdown) {
165166 _channel.sink.close ();
166167 } else {
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import 'dart:async';
66import 'dart:js_interop' ;
77import 'dart:typed_data' ;
88
9- import 'io.dart' ;
109import 'js.dart' ;
1110import 'sync_message_port.dart' ;
1211import 'worker_threads.dart' ;
@@ -46,14 +45,6 @@ class ReusableIsolate {
4645 workerData: channel.port2,
4746 transferList: [channel.port2].toJS,
4847 argv: argv));
49- worker.once (
50- 'exit' ,
51- (int code) {
52- // Worker exit code 1 means it is killed by worker.terminate()
53- if (code > exitCode && code != 1 ) {
54- exitCode = code;
55- }
56- }.toJS);
5748 var controller = StreamController <dynamic >(sync : true );
5849 var sendPort = SyncMessagePort (channel.port1);
5950 var receivePort = channel.port1;
You can’t perform that action at this time.
0 commit comments