@@ -41,6 +41,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
4141 var debugFile string
4242 var debugFiltersArg []string
4343 var daemonPort string
44+ var maxGRPCRecvMsgSize int
4445 daemonCommand := & cobra.Command {
4546 Use : "daemon" ,
4647 Short : i18n .Tr ("Run the Arduino CLI as a gRPC daemon." ),
@@ -60,9 +61,14 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
6061 panic ("Failed to set default value for directories.builtin.libraries: " + err .Error ())
6162 }
6263 }
64+
65+ // Validate the maxGRPCRecvMsgSize flag
66+ if maxGRPCRecvMsgSize < 1024 {
67+ feedback .Fatal (i18n .Tr ("%s must be >= 1024" , "--max-grpc-recv-message-size" ), feedback .ErrBadArgument )
68+ }
6369 },
6470 Run : func (cmd * cobra.Command , args []string ) {
65- runDaemonCommand (srv , daemonPort , debugFile , debug , daemonize , debugFiltersArg )
71+ runDaemonCommand (srv , daemonPort , debugFile , debug , daemonize , debugFiltersArg , maxGRPCRecvMsgSize )
6672 },
6773 }
6874 defaultDaemonPort := settings .GetDaemon ().GetPort ()
@@ -82,10 +88,13 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
8288 daemonCommand .Flags ().StringSliceVar (& debugFiltersArg ,
8389 "debug-filter" , []string {},
8490 i18n .Tr ("Display only the provided gRPC calls" ))
91+ daemonCommand .Flags ().IntVar (& maxGRPCRecvMsgSize ,
92+ "max-grpc-recv-message-size" , 16 * 1024 * 1024 ,
93+ i18n .Tr ("Sets the maximum message size in bytes the daemon can receive" ))
8594 return daemonCommand
8695}
8796
88- func runDaemonCommand (srv rpc.ArduinoCoreServiceServer , daemonPort , debugFile string , debug , daemonize bool , debugFiltersArg []string ) {
97+ func runDaemonCommand (srv rpc.ArduinoCoreServiceServer , daemonPort , debugFile string , debug , daemonize bool , debugFiltersArg []string , maxGRPCRecvMsgSize int ) {
8998 logrus .Info ("Executing `arduino-cli daemon`" )
9099
91100 gRPCOptions := []grpc.ServerOption {}
@@ -116,6 +125,7 @@ func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort, debugFile st
116125 grpc .StreamInterceptor (streamLoggerInterceptor ),
117126 )
118127 }
128+ gRPCOptions = append (gRPCOptions , grpc .MaxRecvMsgSize (maxGRPCRecvMsgSize ))
119129 s := grpc .NewServer (gRPCOptions ... )
120130
121131 // register the commands service
0 commit comments