File tree 3 files changed +35
-3
lines changed
3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change 45
45
dart analyze test/
46
46
47
47
- name : Run tests
48
- run : dart run test
48
+ run : dart run test --concurrency=1
Original file line number Diff line number Diff line change @@ -448,7 +448,9 @@ class PhoenixSocket {
448
448
return false ;
449
449
} catch (error, stackTrace) {
450
450
_logger.warning ('Heartbeat message failed' , error, stackTrace);
451
- _reconnect (heartbeatTimedOut, reason: 'Heartbeat timed out' );
451
+ if (! _disposed && _connectionManager != null ) {
452
+ _reconnect (heartbeatTimedOut, reason: 'Heartbeat timed out' );
453
+ }
452
454
return false ;
453
455
}
454
456
}
@@ -569,7 +571,6 @@ class PhoenixSocket {
569
571
if (_isOpen) {
570
572
_triggerChannelExceptions (PhoenixException (socketError: errorEvent));
571
573
}
572
- // _connectionManager?.reconnect(internalServerError, reason: 'Error on socket: ${errorEvent.error}');
573
574
}
574
575
575
576
void _onSocketClosed (PhoenixSocketCloseEvent closeEvent) {
Original file line number Diff line number Diff line change @@ -3,10 +3,20 @@ import 'dart:async';
3
3
import 'package:phoenix_socket/phoenix_socket.dart' ;
4
4
import 'package:test/test.dart' ;
5
5
6
+ import 'helpers/proxy.dart' ;
7
+
6
8
void main () {
7
9
const addr = 'ws://localhost:4001/socket/websocket' ;
8
10
9
11
group ('PhoenixSocket' , () {
12
+ setUp (() async {
13
+ await prepareProxy ();
14
+ });
15
+
16
+ tearDown (() async {
17
+ await destroyProxy ();
18
+ });
19
+
10
20
test ('can connect to a running Phoenix server' , () async {
11
21
final socket = PhoenixSocket (addr);
12
22
@@ -121,5 +131,26 @@ void main() {
121
131
122
132
expect (errCount, 3 );
123
133
});
134
+
135
+ test ('heartbeat failure does not reconnect after disposal' , () async {
136
+ final socket = PhoenixSocket (
137
+ addr,
138
+ socketOptions: PhoenixSocketOptions (
139
+ heartbeat: Duration (milliseconds: 1 ),
140
+ ),
141
+ );
142
+
143
+ await socket.connect ();
144
+
145
+ await socket.openStream.first;
146
+
147
+ // Prevent next heartbeat from getting a reply.
148
+ await haltProxy ();
149
+
150
+ socket.dispose ();
151
+
152
+ await Future .delayed (Duration (milliseconds: 1 ));
153
+ // The test will fail with unhandled exception if reconnection attempt is made
154
+ });
124
155
});
125
156
}
You can’t perform that action at this time.
0 commit comments