File tree 3 files changed +10
-17
lines changed
3 files changed +10
-17
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
@@ -366,14 +367,14 @@ final class CompilationDispatcher {
366
367
message.writeToCodedBufferWriter (protobufWriter);
367
368
368
369
// Add one additional byte to the beginning to indicate whether or not the
369
- // compilation has finished (1) or encountered a fatal error (2 ), so the
370
+ // compilation has finished (1) or encountered a fatal error (exitCode ), so the
370
371
// [IsolateDispatcher] knows whether to treat this isolate as inactive or
371
372
// close out entirely.
372
373
var packet = Uint8List (
373
374
1 + _compilationIdVarint.length + protobufWriter.lengthInBytes);
374
375
packet[0 ] = switch (message.whichMessage ()) {
375
376
OutboundMessage_Message .compileResponse => 1 ,
376
- OutboundMessage_Message .error => 2 ,
377
+ OutboundMessage_Message .error => exitCode ,
377
378
_ => 0
378
379
};
379
380
packet.setAll (1 , _compilationIdVarint);
Original file line number Diff line number Diff line change @@ -127,11 +127,11 @@ class IsolateDispatcher {
127
127
var fullBuffer = message as Uint8List ;
128
128
129
129
// The first byte of messages from isolates indicates whether the entire
130
- // compilation is finished (1) or if it encountered an error (2). Sending
131
- // this as part of the message buffer rather than a separate message
132
- // avoids a race condition where the host might send a new compilation
133
- // request with the same ID as one that just finished before the
134
- // [IsolateDispatcher] receives word that the isolate with that ID is
130
+ // compilation is finished (1) or if it encountered an error (exitCode).
131
+ // Sending this as part of the message buffer rather than a separate
132
+ // message avoids a race condition where the host might send a new
133
+ // compilation request with the same ID as one that just finished before
134
+ // the [IsolateDispatcher] receives word that the isolate with that ID is
135
135
// done. See sass/dart-sass#2004.
136
136
var category = fullBuffer[0 ];
137
137
var packet = Uint8List .sublistView (fullBuffer, 1 );
@@ -145,8 +145,9 @@ class IsolateDispatcher {
145
145
_inactiveIsolates.add (isolate);
146
146
resource.release ();
147
147
_channel.sink.add (packet);
148
- case 2 :
148
+ default :
149
149
_channel.sink.add (packet);
150
+ exitCode = category;
150
151
if (_gracefulShutdown) {
151
152
_channel.sink.close ();
152
153
} 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