From 7e4767953d5399fdd0200f18b5a88a59d81cb9ad Mon Sep 17 00:00:00 2001
From: Will Demaine <willdemaine@gmail.com>
Date: Sun, 23 Feb 2025 11:59:55 +0000
Subject: [PATCH] Increase max message size

---
 cli/cmd/encore/cmdutil/daemon.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/cli/cmd/encore/cmdutil/daemon.go b/cli/cmd/encore/cmdutil/daemon.go
index 8762c10196..728532cd96 100644
--- a/cli/cmd/encore/cmdutil/daemon.go
+++ b/cli/cmd/encore/cmdutil/daemon.go
@@ -155,11 +155,14 @@ func dialDaemon(ctx context.Context, socketPath string) (*grpc.ClientConn, error
 	dialer := func(ctx context.Context, addr string) (net.Conn, error) {
 		return (&net.Dialer{}).DialContext(ctx, "unix", socketPath)
 	}
+	// Set max message size to 16mb (up from default 4mb) for json formatted debug metadata for large applications.
 	return grpc.DialContext(ctx, "",
 		grpc.WithInsecure(),
 		grpc.WithBlock(),
 		grpc.WithUnaryInterceptor(errInterceptor),
-		grpc.WithContextDialer(dialer))
+		grpc.WithContextDialer(dialer),
+		grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(16*1024*1024)),
+	)
 }
 
 func errInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {