Repository navigation
fix(batch): avoid mutating the payload when rendering react emails - #1136
Merged
Merged
Conversation
felipefreitag
approved these changes
Oct 15, 2026
commit: |
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.
#862 stopped
emails,broadcastsandtemplatesfrom mutating the caller's payload, butbatchstill writes onto each email object when rendering a React component:So after
resend.batch.send(emails), the caller's objects have lostreactand gained a renderedhtmlstring. If the objects are frozen (e.g.Object.freeze, Immer/Redux state), it throwsTypeError: Cannot add property html, object is not extensibleinstead of returning{ data, error }.This copies each email before rendering, the same way #862 does for the other resources.
How to test it
Added two tests to
batch.spec.ts:batch.create()with a React emailerror: nullinstead of throwingBoth fail on
canaryand pass with this change.pnpm lint,typecheckand the full test suite pass.Summary by cubic
Fixes
batchmutating the caller's email payloads when React components are used.batch.createandbatch.sendpreviously wrote a renderedhtmlstring onto each email and removed itsreactproperty, which threw aTypeErrorwhen the payload was frozen (e.g. withObject.freezeor Immer state). Each email is now copied before rendering, matching the fix already applied toemails,broadcasts, andtemplates.Written for commit 24b9484. Summary will update on new commits.