File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
site/src/components/Resources Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ import type {
1010 WorkspaceAgentMetadata ,
1111} from "api/typesGenerated" ;
1212import { DropdownArrow } from "components/DropdownArrow/DropdownArrow" ;
13- import { displayError } from "components/GlobalSnackbar/utils" ;
1413import { VSCodeDesktopButton } from "components/Resources/VSCodeDesktopButton/VSCodeDesktopButton" ;
1514import {
1615 Line ,
@@ -472,6 +471,11 @@ const useAgentLogs = (
472471 // Get all logs
473472 after : 0 ,
474473 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+
475479 setLogs ( ( previousLogs ) => {
476480 const newLogs : LineWithID [ ] = logs . map ( ( log ) => ( {
477481 id : log . id ,
@@ -488,8 +492,14 @@ const useAgentLogs = (
488492 return [ ...previousLogs , ...newLogs ] ;
489493 } ) ;
490494 } ,
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 ) ;
493503 } ,
494504 } ) ;
495505
You can’t perform that action at this time.
0 commit comments