-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: clearState not working when lambda throws error #1027
Comments
Hey @Crafoord thank you for reporting this and providing a reproduction example. Please give us some time to look into it, we'll get back to you as soon as we can. |
Thanks again for reporting this bug @Crafoord. CloudWatch Logs Insights query:
We will start working on a fix right away and adding this scenario to our E2E tests. |
|
This will be part of the next release. I am going to add the scenario in our E2E tests in a future PR (it requires some refactoring). |
Bug description
When using
addPersistentLogAttributes
:and using the middy to clearState:
and then exiting the lambda by throwing an error, the next invocation will still have the persistentLogAttributes present. My guess is that the middleware never runs because of the error.
Expected Behavior
When lambda crashes the middleware should still
clearState
.Current Behavior
When lambda crashes the middleware does not
clearState
.Possible Solution
I guess there could be a way of handling this by not using middleware but there is no documentation of how to
clearState
without it.Steps to Reproduce
Before adding memberId
will not have memberId property,After adding memberId
will have memberId: testBefore adding memberId
will have memberId: test (which is not supposed to be there).Environment
"@aws-lambda-powertools/logger": "^1.0.2",
"@middy/core": "^3.1.0"
Lambda runtime: nodejs16.x
The text was updated successfully, but these errors were encountered: