@@ -79,7 +79,10 @@ func (fso *FileServiceOperator) File(
7979 defer backoffCancel ()
8080
8181 getFile := func () (* mpi.GetFileResponse , error ) {
82- return fso .fileServiceClient .GetFile (ctx , & mpi.GetFileRequest {
82+ grpcCtx , cancel := context .WithTimeout (ctx , fso .agentConfig .Client .FileDownloadTimeout )
83+ defer cancel ()
84+
85+ return fso .fileServiceClient .GetFile (grpcCtx , & mpi.GetFileRequest {
8386 MessageMeta : & mpi.MessageMeta {
8487 MessageId : id .GenerateMessageID (),
8588 CorrelationId : logger .CorrelationID (ctx ),
@@ -225,7 +228,10 @@ func (fso *FileServiceOperator) ChunkedFile(
225228) error {
226229 slog .DebugContext (ctx , "Getting chunked file" , "file" , file .GetFileMeta ().GetName ())
227230
228- stream , err := fso .fileServiceClient .GetFileStream (ctx , & mpi.GetFileRequest {
231+ grpcCtx , cancel := context .WithTimeout (ctx , fso .agentConfig .Client .FileDownloadTimeout )
232+ defer cancel ()
233+
234+ stream , err := fso .fileServiceClient .GetFileStream (grpcCtx , & mpi.GetFileRequest {
229235 MessageMeta : & mpi.MessageMeta {
230236 MessageId : id .GenerateMessageID (),
231237 CorrelationId : logger .CorrelationID (ctx ),
@@ -388,12 +394,15 @@ func (fso *FileServiceOperator) sendUpdateFileRequest(
388394 return nil , errors .New ("CreateConnection rpc has not being called yet" )
389395 }
390396
391- response , updateError := fso .fileServiceClient .UpdateFile (ctx , request )
397+ grpcCtx , cancel := context .WithTimeout (ctx , fso .agentConfig .Client .FileDownloadTimeout )
398+ defer cancel ()
399+
400+ response , updateError := fso .fileServiceClient .UpdateFile (grpcCtx , request )
392401
393402 validatedError := internalgrpc .ValidateGrpcError (updateError )
394403
395404 if validatedError != nil {
396- slog .ErrorContext (ctx , "Failed to send update file" , "error" , validatedError )
405+ slog .ErrorContext (grpcCtx , "Failed to send update file" , "error" , validatedError )
397406
398407 return nil , validatedError
399408 }
@@ -423,7 +432,10 @@ func (fso *FileServiceOperator) sendUpdateFileStream(
423432 return errors .New ("file chunk size must be greater than zero" )
424433 }
425434
426- updateFileStreamClient , err := fso .fileServiceClient .UpdateFileStream (ctx )
435+ grpcCtx , cancel := context .WithTimeout (ctx , fso .agentConfig .Client .FileDownloadTimeout )
436+ defer cancel ()
437+
438+ updateFileStreamClient , err := fso .fileServiceClient .UpdateFileStream (grpcCtx )
427439 if err != nil {
428440 return err
429441 }
0 commit comments