-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Expected Behavior
It should not keep attempting to remove from the log buffer (if it's currently empty).
Current Behavior
It keeps attempting to remove from the buffer even if the buffer is empty.
There are checks to make sure that the item size is less than or equal to the maximum size however, subsequent checks check that the item size + buffer size is less than the maximum size.
So in an execution where:
maxBytes is 20000
item size is 20000
buffer size is 0
there would be an infinite loop because while it attempts to remove from the map.
if item size was greater than item size, it would have thrown an error instead.
Code snippet
link to code:
Steps to Reproduce
- Enable buffered logs
- get log data that would be exactly same as the maxBytes specified
Possible Solution
Either check that the item size is definitely less than max bytes (not less than or equal)
or only attempt to remove from the buffer if there is something in the buffer
while (buffer.currentBytesSize + item.byteSize >= this.#maxBytesSize && buffer.currentBytesSize) {Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
22.x
Packaging format used
npm
Execution logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status