Open sigurdm opened 8 years ago
It looks like that when Socket.destroy()
is called on a Socket
that hasn't been listened to or written to, the underlying StreamController
is left in its initial state as it has not yet been subscribed to (see _isInitialState
in stream_controller.dart). As such, we add a done
event to the StreamController
's pending events queue, which is where it is kept until a subscription to the Stream
is created. I think we should probably drain the pending events or at least complete the done
Future some other way.
This seems to still be the case in 2.2.1-dev.2.0. @sortie
This still seems to be the case.
Had to make the following workaround:
socket.add(data);
final sub = socket.listen((_) {}, cancelOnError: true);
await socket.done;
print('Request done!');
sub.cancel();
If the listen
isn't present, it will await
for socket.done
forever.
This program never prints "Done". If the line with socket.add is included; "Done" is printed.