File tree 1 file changed +13
-3
lines changed
site/src/components/Resources
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import type {
10
10
WorkspaceAgentMetadata ,
11
11
} from "api/typesGenerated" ;
12
12
import { DropdownArrow } from "components/DropdownArrow/DropdownArrow" ;
13
- import { displayError } from "components/GlobalSnackbar/utils" ;
14
13
import { VSCodeDesktopButton } from "components/Resources/VSCodeDesktopButton/VSCodeDesktopButton" ;
15
14
import {
16
15
Line ,
@@ -472,6 +471,11 @@ const useAgentLogs = (
472
471
// Get all logs
473
472
after : 0 ,
474
473
onMessage : ( logs ) => {
474
+ // Prevent new logs getting added when a connection is not open
475
+ if ( socket . current ?. readyState !== WebSocket . OPEN ) {
476
+ return ;
477
+ }
478
+
475
479
setLogs ( ( previousLogs ) => {
476
480
const newLogs : LineWithID [ ] = logs . map ( ( log ) => ( {
477
481
id : log . id ,
@@ -488,8 +492,14 @@ const useAgentLogs = (
488
492
return [ ...previousLogs , ...newLogs ] ;
489
493
} ) ;
490
494
} ,
491
- onError : ( ) => {
492
- displayError ( "Error on getting agent logs" ) ;
495
+ onError : ( error ) => {
496
+ // For some reason Firefox and Safari throw an error when a websocket
497
+ // connection is close in the middle of a message and because of that we
498
+ // can't safely show to the users an error message since most of the
499
+ // time they are just internal stuff. This does not happen to Chrome at
500
+ // all and I tried to find better way to "soft close" a WS connection on
501
+ // those browsers without success.
502
+ console . error ( error ) ;
493
503
} ,
494
504
} ) ;
495
505
You can’t perform that action at this time.
0 commit comments