fix: no mutation for caller owned payloads#996
Merged
ferhatelmas merged 1 commit intomasterfrom Apr 9, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR prevents mutation of caller-owned event payload objects when adding $version, reducing surprising side effects for event callers across sync/async queue paths.
Changes:
- Introduces a
withPayloadVersion()helper to add$versionvia a shallow copy instead of mutating inputs. - Updates
Event.send,Event.invoke,Event.invokeOrSend, andEvent.batchSendto use the copied payload. - Adds Jest coverage ensuring payload objects passed into these APIs are not mutated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/internal/queue/event.ts | Avoids mutating caller payloads by generating a shallow-copied payload with $version for static send/invoke APIs and batch inserts. |
| src/test/event.test.ts | Adds regression tests asserting caller payloads are not mutated and that queued batch payloads still include $version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage Report for CI Build 24196948700Coverage increased (+0.02%) to 80.846%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
fenos
approved these changes
Apr 9, 2026
Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
b79bdad to
d28fea1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Event payloads are mutated to add version but they are owned by their callers.
What is the new behavior?
Do a shallow copy to add version to prevent nasty bugs.
Additional context
Related to any type changes (#922), extracted due to behavior changes.