File tree Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Expand file tree Collapse file tree 4 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ class RealtimeChannel {
7070 socket.remove (this );
7171 });
7272
73- _onError ((String ? reason) {
73+ _onError ((reason) {
7474 if (isLeaving || isClosed) {
7575 return ;
7676 }
@@ -260,9 +260,9 @@ class RealtimeChannel {
260260 }
261261
262262 /// 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) {
264264 onEvents (ChannelEvents .error.eventName (), ChannelFilter (),
265- (reason, [ref]) => callback (reason? . toString () ));
265+ (reason, [ref]) => callback (reason));
266266 }
267267
268268 /// Sets up a listener on your Supabase database.
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class RealtimeCloseEvent {
4848
4949 @override
5050 String toString () {
51- return 'RealtimeCloseEvent{ code: $code , reason: $reason } ' ;
51+ return 'RealtimeCloseEvent( code: $code , reason: $reason ) ' ;
5252 }
5353}
5454
Original file line number Diff line number Diff line change @@ -268,7 +268,9 @@ void main() {
268268 final subscribeCallback =
269269 expectAsync2 ((RealtimeSubscribeStatus event, error) {
270270 if (event == RealtimeSubscribeStatus .channelError) {
271- expect (error, isNull);
271+ expect (error, isA <RealtimeCloseEvent >());
272+ error as RealtimeCloseEvent ;
273+ expect (error.reason, "heartbeat timeout" );
272274 } else {
273275 expect (event, RealtimeSubscribeStatus .closed);
274276 }
@@ -285,6 +287,7 @@ void main() {
285287
286288 channel.subscribe (subscribeCallback);
287289
290+ await Future .delayed (Duration (milliseconds: 200 ));
288291 await client.conn! .sink
289292 .close (Constants .wsCloseNormal, "heartbeat timeout" );
290293 });
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ void main() {
171171 });
172172
173173 socket.connect ();
174+ await Future .delayed (const Duration (milliseconds: 200 ));
174175 expect (opens, 1 );
175176
176177 socket.sendHeartbeat ();
@@ -229,7 +230,7 @@ void main() {
229230 expect (closes, 1 );
230231 });
231232
232- test ('calls connection close callback' , () {
233+ test ('calls connection close callback' , () async {
233234 final mockedSocketChannel = MockIOWebSocketChannel ();
234235 final mockedSocket = RealtimeClient (
235236 socketEndpoint,
@@ -247,7 +248,10 @@ void main() {
247248 const tReason = 'reason' ;
248249
249250 mockedSocket.connect ();
251+ mockedSocket.connState = SocketStates .open;
252+ await Future .delayed (const Duration (milliseconds: 200 ));
250253 mockedSocket.disconnect (code: tCode, reason: tReason);
254+ await Future .delayed (const Duration (milliseconds: 200 ));
251255
252256 verify (
253257 () => mockedSink.close (
You can’t perform that action at this time.
0 commit comments