File tree 4 files changed +13
-6
lines changed
4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ class RealtimeChannel {
70
70
socket.remove (this );
71
71
});
72
72
73
- _onError ((String ? reason) {
73
+ _onError ((reason) {
74
74
if (isLeaving || isClosed) {
75
75
return ;
76
76
}
@@ -260,9 +260,9 @@ class RealtimeChannel {
260
260
}
261
261
262
262
/// Registers a callback that will be executed when the channel encounteres an error.
263
- void _onError (void Function ( String ? ) callback) {
263
+ void _onError (Function callback) {
264
264
onEvents (ChannelEvents .error.eventName (), ChannelFilter (),
265
- (reason, [ref]) => callback (reason? . toString () ));
265
+ (reason, [ref]) => callback (reason));
266
266
}
267
267
268
268
/// Sets up a listener on your Supabase database.
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class RealtimeCloseEvent {
48
48
49
49
@override
50
50
String toString () {
51
- return 'RealtimeCloseEvent{ code: $code , reason: $reason } ' ;
51
+ return 'RealtimeCloseEvent( code: $code , reason: $reason ) ' ;
52
52
}
53
53
}
54
54
Original file line number Diff line number Diff line change @@ -268,7 +268,9 @@ void main() {
268
268
final subscribeCallback =
269
269
expectAsync2 ((RealtimeSubscribeStatus event, error) {
270
270
if (event == RealtimeSubscribeStatus .channelError) {
271
- expect (error, isNull);
271
+ expect (error, isA <RealtimeCloseEvent >());
272
+ error as RealtimeCloseEvent ;
273
+ expect (error.reason, "heartbeat timeout" );
272
274
} else {
273
275
expect (event, RealtimeSubscribeStatus .closed);
274
276
}
@@ -285,6 +287,7 @@ void main() {
285
287
286
288
channel.subscribe (subscribeCallback);
287
289
290
+ await Future .delayed (Duration (milliseconds: 200 ));
288
291
await client.conn! .sink
289
292
.close (Constants .wsCloseNormal, "heartbeat timeout" );
290
293
});
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ void main() {
171
171
});
172
172
173
173
socket.connect ();
174
+ await Future .delayed (const Duration (milliseconds: 200 ));
174
175
expect (opens, 1 );
175
176
176
177
socket.sendHeartbeat ();
@@ -229,7 +230,7 @@ void main() {
229
230
expect (closes, 1 );
230
231
});
231
232
232
- test ('calls connection close callback' , () {
233
+ test ('calls connection close callback' , () async {
233
234
final mockedSocketChannel = MockIOWebSocketChannel ();
234
235
final mockedSocket = RealtimeClient (
235
236
socketEndpoint,
@@ -247,7 +248,10 @@ void main() {
247
248
const tReason = 'reason' ;
248
249
249
250
mockedSocket.connect ();
251
+ mockedSocket.connState = SocketStates .open;
252
+ await Future .delayed (const Duration (milliseconds: 200 ));
250
253
mockedSocket.disconnect (code: tCode, reason: tReason);
254
+ await Future .delayed (const Duration (milliseconds: 200 ));
251
255
252
256
verify (
253
257
() => mockedSink.close (
You can’t perform that action at this time.
0 commit comments