File tree 2 files changed +14
-0
lines changed 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 4
4
* Remove generated status codes.
5
5
* Remove dependency on ` package:archive ` .
6
6
* Move ` codec.dart ` .
7
+ * Work around hang during Flutter hot restart by adding default case handler in _ GrpcWebConversionSink.add.
7
8
8
9
## 3.2.4
9
10
Original file line number Diff line number Diff line change @@ -132,6 +132,16 @@ class _GrpcWebConversionSink implements ChunkedConversionSink<ByteBuffer> {
132
132
void add (ByteBuffer chunk) {
133
133
_chunkOffset = 0 ;
134
134
final chunkData = chunk.asUint8List ();
135
+ // in flutter web, when a hot-restart is requested, the code can get stuck
136
+ // in the following loop if there is an active streaming call. the
137
+ // switch statement is invoked but doesn't match any of the cases. this
138
+ // presumably has something to do how enums work across isolates.
139
+ // possibly related to https://github.com/dart-lang/sdk/issues/35626.
140
+ //
141
+ // in any case, adding a default handler to the switch statement
142
+ // causes this loop to end in that case, allowing the old isolate
143
+ // to shut down and the hot-restart to work properly.
144
+ processingLoop:
135
145
while (_chunkOffset < chunk.lengthInBytes) {
136
146
switch (_state) {
137
147
case _GrpcWebParseState .init:
@@ -143,6 +153,9 @@ class _GrpcWebConversionSink implements ChunkedConversionSink<ByteBuffer> {
143
153
case _GrpcWebParseState .message:
144
154
_parseMessage (chunkData);
145
155
break ;
156
+ default :
157
+ // only expected to be hit when hot-restarting, see above
158
+ break processingLoop;
146
159
}
147
160
}
148
161
_chunkOffset = 0 ;
You can’t perform that action at this time.
0 commit comments