@@ -123,7 +123,7 @@ pub async fn prompt_accessibility_command() -> Result<()> {
123123
124124pub async fn update_command ( force : bool ) -> Result < Option < CommandResponse > > {
125125 let command = command:: Command :: Update ( UpdateCommand { force } ) ;
126- send_recv_command_to_socket ( command) . await
126+ send_recv_command_to_socket_with_timeout ( command, std :: time :: Duration :: from_secs ( 120 ) ) . await
127127}
128128
129129pub async fn restart_command ( ) -> Result < ( ) > {
@@ -155,7 +155,11 @@ pub async fn devtools_command(window: devtools_command::Window) -> Result<()> {
155155pub trait LocalIpc : SendRecvMessage {
156156 async fn send_hook ( & mut self , hook : local:: Hook ) -> Result < ( ) > ;
157157 async fn send_command ( & mut self , command : local:: command:: Command , response : bool ) -> Result < ( ) > ;
158- async fn send_recv_command ( & mut self , command : local:: command:: Command ) -> Result < Option < local:: CommandResponse > > ;
158+ async fn send_recv_command (
159+ & mut self ,
160+ command : local:: command:: Command ,
161+ timeout : Duration ,
162+ ) -> Result < Option < local:: CommandResponse > > ;
159163}
160164
161165#[ async_trait]
@@ -183,10 +187,15 @@ where
183187 Ok ( self . send_message ( message) . await ?)
184188 }
185189
186- /// Send a command to and recv a response from the desktop app
187- async fn send_recv_command ( & mut self , command : local:: command:: Command ) -> Result < Option < local:: CommandResponse > > {
190+ /// Send a command to and recv a response from the desktop app, with a configurable timeout on
191+ /// the response
192+ async fn send_recv_command (
193+ & mut self ,
194+ command : local:: command:: Command ,
195+ timeout : Duration ,
196+ ) -> Result < Option < local:: CommandResponse > > {
188197 self . send_command ( command, true ) . await ?;
189- Ok ( tokio:: time:: timeout ( Duration :: from_secs ( 2 ) , self . recv_message ( ) )
198+ Ok ( tokio:: time:: timeout ( timeout , self . recv_message ( ) )
190199 . await
191200 . or ( Err ( Error :: Timeout ) ) ??)
192201 }
@@ -206,7 +215,14 @@ pub async fn send_command_to_socket(command: local::command::Command) -> Result<
206215}
207216
208217pub async fn send_recv_command_to_socket ( command : local:: command:: Command ) -> Result < Option < local:: CommandResponse > > {
218+ send_recv_command_to_socket_with_timeout ( command, Duration :: from_secs ( 2 ) ) . await
219+ }
220+
221+ pub async fn send_recv_command_to_socket_with_timeout (
222+ command : local:: command:: Command ,
223+ timeout : Duration ,
224+ ) -> Result < Option < local:: CommandResponse > > {
209225 let path = directories:: desktop_socket_path ( ) ?;
210226 let mut conn = BufferedUnixStream :: connect_timeout ( & path, Duration :: from_secs ( 3 ) ) . await ?;
211- conn. send_recv_command ( command) . await
227+ conn. send_recv_command ( command, timeout ) . await
212228}
0 commit comments