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 3
3
// https://opensource.org/licenses/MIT.
4
4
5
5
import 'dart:convert' ;
6
+ import 'dart:io' if (dart.library.js) 'js/io.dart' ;
6
7
import 'dart:isolate' if (dart.library.js) 'js/isolate.dart' ;
7
8
import 'dart:typed_data' ;
8
9
@@ -408,16 +409,16 @@ final class CompilationDispatcher {
408
409
message.writeToCodedBufferWriter (protobufWriter);
409
410
410
411
// 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.
414
415
var packet = Uint8List (
415
416
1 + _compilationIdVarint.length + protobufWriter.lengthInBytes,
416
417
);
417
418
packet[0 ] = switch (message.whichMessage ()) {
418
419
OutboundMessage_Message .compileResponse => 1 ,
419
- OutboundMessage_Message .error => 2 ,
420
- _ => 0 ,
420
+ OutboundMessage_Message .error => exitCode ,
421
+ _ => 0
421
422
};
422
423
packet.setAll (1 , _compilationIdVarint);
423
424
protobufWriter.writeTo (packet, 1 + _compilationIdVarint.length);
Original file line number Diff line number Diff line change @@ -141,11 +141,11 @@ class IsolateDispatcher {
141
141
var fullBuffer = message as Uint8List ;
142
142
143
143
// 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
149
149
// done. See sass/dart-sass#2004.
150
150
var category = fullBuffer[0 ];
151
151
var packet = Uint8List .sublistView (fullBuffer, 1 );
@@ -159,8 +159,9 @@ class IsolateDispatcher {
159
159
_inactiveIsolates.add (isolate);
160
160
resource.release ();
161
161
_channel.sink.add (packet);
162
- case 2 :
162
+ default :
163
163
_channel.sink.add (packet);
164
+ exitCode = category;
164
165
if (_gracefulShutdown) {
165
166
_channel.sink.close ();
166
167
} else {
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import 'dart:async';
6
6
import 'dart:js_interop' ;
7
7
import 'dart:typed_data' ;
8
8
9
- import 'io.dart' ;
10
9
import 'js.dart' ;
11
10
import 'sync_message_port.dart' ;
12
11
import 'worker_threads.dart' ;
@@ -46,14 +45,6 @@ class ReusableIsolate {
46
45
workerData: channel.port2,
47
46
transferList: [channel.port2].toJS,
48
47
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);
57
48
var controller = StreamController <dynamic >(sync : true );
58
49
var sendPort = SyncMessagePort (channel.port1);
59
50
var receivePort = channel.port1;
You can’t perform that action at this time.
0 commit comments