File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -2184,6 +2184,8 @@ class _SocketStreamConsumer implements StreamConsumer<List<int>> {
2184
2184
assert (buffer == null );
2185
2185
done ();
2186
2186
}, cancelOnError: true );
2187
+ } else {
2188
+ done ();
2187
2189
}
2188
2190
return completer.future;
2189
2191
}
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ // Tests that adding a stream to a `Socket` that has been `destroy`ed returns
6
+ // a `Future` that completes.
7
+
8
+ import "dart:async" ;
9
+ import "dart:io" ;
10
+
11
+ import "package:async_helper/async_helper.dart" ;
12
+ import "package:expect/expect.dart" ;
13
+
14
+ void main () async {
15
+ asyncStart ();
16
+
17
+ final server = await ServerSocket .bind ("127.0.0.1" , 0 );
18
+ late final Socket connectedSocket;
19
+ server.listen ((socket) {
20
+ // Note: must keep socket alive for the duration of the test.
21
+ // Otherwise GC might collect it and and shutdown this side of socket
22
+ // which would cause writing to abort.
23
+ connectedSocket = socket;
24
+ // Passive block data by not subscribing to socket.
25
+ });
26
+
27
+ final client = await Socket .connect ("127.0.0.1" , server.port);
28
+ client.listen ((data) {}, onDone: server.close);
29
+ client.add (new List .filled (1024 * 1024 , 0 ));
30
+ client.destroy ();
31
+ await client.addStream (Stream .fromIterable ([
32
+ [1 , 2 , 3 , 4 ]
33
+ ]));
34
+ asyncEnd ();
35
+ }
You can’t perform that action at this time.
0 commit comments