brefphp/bref

Handle "Response too big" in Console functions

ddeboer opened this issue · 2 comments

When invoking a (Symfony CLI) Lambda that outputs a lot of logging, I see a ResponseTooBig error:

Invoke Error	{"errorType":"Bref\\Runtime\\ResponseTooBig","errorMessage":"The Lambda response is too big and above the limit: 6 MB for HTTP responses and other synchronous invocations, 256 KB for asynchronous invocations (https:\/\/docs.aws.amazon.com\/lambda\/latest\/dg\/gettingstarted-limits.html#function-configuration-deployment-and-execution)","stack":["#0 \/var\/task\/vendor\/bref\/bref\/src\/Runtime\/LambdaRuntime.php(190): Bref\\Runtime\\LambdaRuntime->postJson('http:\/\/127.0.0....', Array)","#1 \/var\/task\/vendor\/bref\/bref\/src\/Runtime\/LambdaRuntime.php(96): Bref\\Runtime\\LambdaRuntime->sendResponse('abffc807-7372-4...', Array)","#2 \/var\/task\/vendor\/bref\/bref\/src\/ConsoleRuntime\/Main.php(36): Bref\\Runtime\\LambdaRuntime->processNextEvent(Object(Closure))","#3 \/opt\/bref\/bootstrap.php(17): Bref\\ConsoleRuntime\\Main::run()","#4 {main}"]}

The error is triggered by Lambda’s 6 MB request/response payload limit.

I’d like to keep the verbosity of the logs to CloudWatch, but not have them all printed to stdout/stderr, which causes the response to become too big. Is it possible to differentiate between CloudWatch and CLI output?

Right now it's not possible indeed, could be an improvement to add 👍

Should be fixed by #1809