perf: improve enforce_payload_size_limit #122
Draft
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.
Description 📝
Purpose:
As reported internally:
I am not sure what exactly the error here was, but I investigated a bit and saw that the code handling the
enforce_payload_size_limit
was performing a deep copy of the error payload before applying the size limits:This seems unnecessary, as we are just going to send the payload and then discard it.
Approach:
The code has been simplified, and now it uses the error payload directly:
However, we need to be careful with global variables.
If
transmitGlobalVariables
is set totrue
(which is default), then global variables are also included in the payload. Because theenforce_payload_size_limit
logic removes them, we need to ensure those global variables are copied and not modified.For that, we do a copy of the global variables when adding them to the error payload info:
Note: Maybe in the context of the mentioned project, we want to use
transmitGlobalVariables
set tofalse
.Type of change
fix:
Bug fix (non-breaking change which fixes an issue)feat:
New feature (non-breaking change which adds functionality)chore:
Chore task, release or small impact changeci:
CI configuration changeUpdates
enforce_payload_size_limit
handling codeRelated issues
Test plan 🧪
Run the tests and samples to verify everything works as before
Author to check 👓
Reviewer to check ✔️