Skip to content

fix: prevent payload mutation and parallelize batch rendering#853

Closed
Ray0907 wants to merge 1 commit into
resend:canaryfrom
Ray0907:fix/immutable-rendering-and-parallel-batch
Closed

fix: prevent payload mutation and parallelize batch rendering#853
Ray0907 wants to merge 1 commit into
resend:canaryfrom
Ray0907:fix/immutable-rendering-and-parallel-batch

Conversation

@Ray0907
Copy link
Copy Markdown

@Ray0907 Ray0907 commented Feb 20, 2026

  • Fix payload mutation in emails.create(), templates.create(), and
    batch.create() — these methods currently modify the caller's input object
    (payload.html = ..., email.react = undefined), which can cause bugs when reusing the
    same options object across multiple calls
  • Parallelize batch rendering — replace sequential for...of + await with
    Promise.all, so React template rendering for batch emails runs concurrently instead of
    one-by-one

Summary by cubic

Prevents payload mutation across email/template/batch APIs and runs batch React rendering in parallel to speed up sends. Removes side effects when reusing options objects and lowers batch latency.

  • Bug Fixes

    • Stop mutating caller input (payload.html, email.react) in emails.create(), templates.create(), and batch.create(); use immutable copies.
  • Performance

    • Parallelize batch React rendering in batch.create() with Promise.all instead of sequential awaits.

Written for commit 24647f5. Summary will update on new commits.

Replace direct mutation (payload.html = ..., email.react = undefined)
with immutable spread patterns across emails.ts, templates.ts, and
batch.ts. Batch rendering now uses Promise.all instead of sequential
for-loop, allowing concurrent React template rendering.
@Ray0907 Ray0907 requested a review from a team as a code owner February 20, 2026 04:49
@Ray0907 Ray0907 requested a review from cassiozen February 20, 2026 04:49
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@gabrielmfern gabrielmfern self-requested a review March 18, 2026 20:55
@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label May 16, 2026
@felipefreitag
Copy link
Copy Markdown
Contributor

Thank you, superseded by #862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants