@@ -256,6 +256,7 @@ impl WorkspaceControllerActor {
256
256
Ok ( ( ) )
257
257
}
258
258
259
+ #[ instrument( level = "trace" , skip_all) ]
259
260
pub ( crate ) fn set_connection_status ( & self , status : ConnectionStatus ) {
260
261
sync_trace ! ( "set connection status: {:?}" , status) ;
261
262
self . status_tx . send_replace ( status) ;
@@ -305,6 +306,7 @@ impl WorkspaceControllerActor {
305
306
}
306
307
}
307
308
309
+ #[ instrument( level = "trace" , skip_all) ]
308
310
async fn handle_action ( actor : & Arc < Self > , action : WorkspaceAction ) {
309
311
let id = actor. db . client_id ( ) ;
310
312
sync_trace ! ( "[{}] action {:?}" , id, action) ;
@@ -358,6 +360,7 @@ impl WorkspaceControllerActor {
358
360
}
359
361
}
360
362
363
+ #[ instrument( level = "trace" , skip_all) ]
361
364
async fn handle_send ( & self , msg : ClientMessage , source : ActionSource ) -> anyhow:: Result < ( ) > {
362
365
if let ClientMessage :: Update {
363
366
object_id,
@@ -422,7 +425,7 @@ impl WorkspaceControllerActor {
422
425
. borrow ( )
423
426
. disconnected_reason ( )
424
427
. as_ref ( )
425
- . map ( |v| v. retriable ( ) || matches ! ( v , DisconnectedReason :: ReachMaximumRetry ) )
428
+ . map ( |v| v. retriable_when_editing ( ) )
426
429
. unwrap_or ( false ) ;
427
430
428
431
if should_retry {
@@ -441,6 +444,7 @@ impl WorkspaceControllerActor {
441
444
}
442
445
}
443
446
447
+ #[ instrument( level = "trace" , skip_all) ]
444
448
pub ( crate ) async fn handle_connect (
445
449
actor : & Arc < Self > ,
446
450
access_token : String ,
@@ -469,7 +473,12 @@ impl WorkspaceControllerActor {
469
473
470
474
match result {
471
475
None => {
472
- actor. set_connection_status ( ConnectionStatus :: Disconnected { reason : None } ) ;
476
+ sync_info ! ( "[{}] connection established failed" , actor. db. client_id( ) ) ;
477
+ actor. set_connection_status ( ConnectionStatus :: Disconnected {
478
+ reason : Some ( DisconnectedReason :: Unexpected (
479
+ "Establish connect failed" . into ( ) ,
480
+ ) ) ,
481
+ } ) ;
473
482
} ,
474
483
Some ( connection) => {
475
484
sync_debug ! ( "[{}] connected to {}" , client_id, actor. options. url) ;
@@ -502,6 +511,7 @@ impl WorkspaceControllerActor {
502
511
let reason = Self :: remote_receiver_loop ( weak_actor. clone ( ) , stream, cancel. clone ( ) )
503
512
. await
504
513
. err ( ) ;
514
+
505
515
if let Some ( actor) = weak_actor. upgrade ( ) {
506
516
if reason. is_some ( ) {
507
517
sync_error ! ( "failed to receive messages from server: {:?}" , reason) ;
@@ -521,7 +531,7 @@ impl WorkspaceControllerActor {
521
531
while let Some ( res) = stream. next ( ) . await {
522
532
if cancel. is_cancelled ( ) {
523
533
sync_trace ! ( "remote receiver loop cancelled" ) ;
524
- break ;
534
+ return Err ( DisconnectedReason :: UserDisconnect ( "User disconnect" . into ( ) ) ) ;
525
535
}
526
536
let actor = match weak_actor. upgrade ( ) {
527
537
Some ( inner) => inner,
@@ -580,8 +590,7 @@ impl WorkspaceControllerActor {
580
590
frame. reason
581
591
) ,
582
592
}
583
- cancel. cancel ( ) ;
584
- break ;
593
+ return Err ( DisconnectedReason :: ServerForceClose ) ;
585
594
} ,
586
595
}
587
596
}
@@ -1112,17 +1121,17 @@ impl WorkspaceControllerActor {
1112
1121
res = fut => {
1113
1122
match res {
1114
1123
Ok ( ( stream, _resp) ) => {
1115
- info !( "establishing WebSocket successfully" ) ;
1124
+ sync_info !( "establishing WebSocket successfully" ) ;
1116
1125
Ok ( Some ( stream) )
1117
1126
} ,
1118
1127
Err ( err) => {
1119
- error !( "establishing WebSocket failed" ) ;
1128
+ sync_error !( "establishing WebSocket failed" ) ;
1120
1129
Err ( AppError :: from( err) . into( ) )
1121
1130
}
1122
1131
}
1123
1132
}
1124
1133
_ = cancel. cancelled( ) => {
1125
- tracing:: debug!( "connection cancelled" ) ;
1134
+ tracing:: debug!( "establishing connection cancelled" ) ;
1126
1135
Ok ( None )
1127
1136
}
1128
1137
}
0 commit comments