@@ -41,6 +41,7 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
41
41
var debugFile string
42
42
var debugFiltersArg []string
43
43
var daemonPort string
44
+ var maxGRPCRecvMsgSize int
44
45
daemonCommand := & cobra.Command {
45
46
Use : "daemon" ,
46
47
Short : i18n .Tr ("Run the Arduino CLI as a gRPC daemon." ),
@@ -60,9 +61,14 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
60
61
panic ("Failed to set default value for directories.builtin.libraries: " + err .Error ())
61
62
}
62
63
}
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
+ }
63
69
},
64
70
Run : func (cmd * cobra.Command , args []string ) {
65
- runDaemonCommand (srv , daemonPort , debugFile , debug , daemonize , debugFiltersArg )
71
+ runDaemonCommand (srv , daemonPort , debugFile , debug , daemonize , debugFiltersArg , maxGRPCRecvMsgSize )
66
72
},
67
73
}
68
74
defaultDaemonPort := settings .GetDaemon ().GetPort ()
@@ -82,10 +88,13 @@ func NewCommand(srv rpc.ArduinoCoreServiceServer, settings *rpc.Configuration) *
82
88
daemonCommand .Flags ().StringSliceVar (& debugFiltersArg ,
83
89
"debug-filter" , []string {},
84
90
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" ))
85
94
return daemonCommand
86
95
}
87
96
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 ) {
89
98
logrus .Info ("Executing `arduino-cli daemon`" )
90
99
91
100
gRPCOptions := []grpc.ServerOption {}
@@ -116,6 +125,7 @@ func runDaemonCommand(srv rpc.ArduinoCoreServiceServer, daemonPort, debugFile st
116
125
grpc .StreamInterceptor (streamLoggerInterceptor ),
117
126
)
118
127
}
128
+ gRPCOptions = append (gRPCOptions , grpc .MaxRecvMsgSize (maxGRPCRecvMsgSize ))
119
129
s := grpc .NewServer (gRPCOptions ... )
120
130
121
131
// register the commands service
0 commit comments