File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 44* Remove generated status codes.
55* Remove dependency on ` package:archive ` .
66* Move ` codec.dart ` .
7+ * Work around hang during Flutter hot restart by adding default case handler in _ GrpcWebConversionSink.add.
78
89## 3.2.4
910
Original file line number Diff line number Diff line change @@ -132,6 +132,16 @@ class _GrpcWebConversionSink implements ChunkedConversionSink<ByteBuffer> {
132132 void add (ByteBuffer chunk) {
133133 _chunkOffset = 0 ;
134134 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:
135145 while (_chunkOffset < chunk.lengthInBytes) {
136146 switch (_state) {
137147 case _GrpcWebParseState .init:
@@ -143,6 +153,9 @@ class _GrpcWebConversionSink implements ChunkedConversionSink<ByteBuffer> {
143153 case _GrpcWebParseState .message:
144154 _parseMessage (chunkData);
145155 break ;
156+ default :
157+ // only expected to be hit when hot-restarting, see above
158+ break processingLoop;
146159 }
147160 }
148161 _chunkOffset = 0 ;
You can’t perform that action at this time.
0 commit comments