Fix #1520 "Unknown application error occurred Runtime.Unknown" #1616
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I finally found the source of the issue 🎉
When failing to get the handler (in the function runtime), the Lambda would fail but would only consider the exception message. It would completely ignore the rest of the exception (stack trace & class name).
In the case of Laravel (which is the most common report for this bug), we would get the following log:
As you can see, the name of the handler class is logged, but that's it. What happens is that Laravel throws an
EntryNotFoundException
: the exception message is only the class name…So the exception message gets logged, but it's not useful, and it looks like the exception wasn't logged at all.
With this PR, the exception message + class name + stack trace will correctly be logged.
On top of that, I refactored how "initialization failures" are reported to have even better logs from Lambda.
Additionally, specifically for this Laravel exception, I will probably catch + rethrow this exception with a clearer message (but this change will go in the Laravel bridge).
Before
Lambda logs:
Lambda invocation result:
After
Lambda logs:
The exception is logged twice because AWS Lambda performs a retry (in the same function, it simply restarts the Bref process).
Lambda invocation result:
Here's a preview with the JSON logs in the Bref Dashboard: