Skip to content

Commit 77c9166

Browse files
[rest_gateway] Raise REST gateway gRPC max receive message size above 4MB default (#2466)
## Related Issues - #2467 ## Summarize your change. GetJobs on a busy facility can return tens of MB (35MB observed on prod), exceeding gRPC's 4MB default and failing with "received message larger than max". Set MaxCallRecvMsgSize to 256MB, overridable via
1 parent e47e327 commit 77c9166

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

  • rest_gateway/opencue_gateway

rest_gateway/opencue_gateway/main.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import (
4848
"log"
4949
"net/http"
5050
"os"
51+
"strconv"
5152
"strings"
5253

5354
"github.com/golang-jwt/jwt/v5"
@@ -203,8 +204,21 @@ func run() error {
203204
// Initialize gRPC-gateway multiplexer for HTTP-to-gRPC translation
204205
mux := runtime.NewServeMux()
205206

206-
// Configure gRPC connection options (using insecure for internal network)
207-
opts := []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}
207+
// Configure gRPC connection options (using insecure for internal network).
208+
// Raise the max receive message size above gRPC's 4MB default so large list
209+
// responses (e.g. GetJobs on a busy production facility — tens of MB) aren't
210+
// rejected with "received message larger than max". Override via
211+
// GRPC_MAX_RECV_MSG_MB (megabytes).
212+
maxRecvMsgBytes := 256 * 1024 * 1024 // 256 MB default
213+
if v := os.Getenv("GRPC_MAX_RECV_MSG_MB"); v != "" {
214+
if mb, err := strconv.Atoi(v); err == nil && mb > 0 {
215+
maxRecvMsgBytes = mb * 1024 * 1024
216+
}
217+
}
218+
opts := []grpc.DialOption{
219+
grpc.WithTransportCredentials(insecure.NewCredentials()),
220+
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxRecvMsgBytes)),
221+
}
208222

209223
// Register all gRPC interface handlers
210224
if err := registerGRPCHandlers(ctx, mux, grpcServerEndpoint, opts); err != nil {

0 commit comments

Comments
 (0)