Skip to content

Sped up email renderer#26870

Open
EvanHahn wants to merge 1 commit intomainfrom
speed-up-email-renderer
Open

Sped up email renderer#26870
EvanHahn wants to merge 1 commit intomainfrom
speed-up-email-renderer

Conversation

@EvanHahn
Copy link
Contributor

no ref

This should be a performance-only change. This patch makes the following changes:

  1. Only read .hbs files once, and only compile the Handlebars template once.
  2. Read .hbs files in parallel, for performance.
  3. Small: don't re-convert a string unnecessarily. (We were reading it as a UTF-8 string, then converting it back to a buffer, then re-reading that buffer as a UTF-8 string.)
  4. Small: don't keep useless references around.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1658ad54-d62a-412b-84de-5318bbe61f74

📥 Commits

Reviewing files that changed from the base of the PR and between a3b8016 and fc6f56a.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/email-service/email-renderer.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/core/core/server/services/email-service/email-renderer.js

Walkthrough

The EmailRenderer was refactored to lazy-compile Handlebars templates. The private fields #handlebars and #renderTemplate were removed and replaced with #compiledHandlebarsRendererPromise. Two new private methods, #compileHandlebarsRenderer() and #getCompiledHandlebarsRenderer(), handle asynchronous compilation and memoization. The public method renderTemplate(data) now awaits and invokes the compiled renderer instead of using a precompiled template. A type annotation for TemplateDelegate was added.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Sped up email renderer' directly captures the main objective of the PR—a performance improvement to the email renderer through lazy compilation and caching.
Description check ✅ Passed The description clearly explains the performance-focused changes including lazy compilation, parallel file reading, and elimination of unnecessary conversions, all aligned with the code modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch speed-up-email-renderer
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

@EvanHahn EvanHahn added the ok to merge for me You can merge this on my behalf if you want. label Mar 18, 2026
no ref

This should be a performance-only change. This patch makes the following
changes:

1. Only read `.hbs` files once, and only compile the Handlebars template
   once.
2. Read `.hbs` files in parallel, for performance.
3. Small: don't re-convert a string unnecessarily. (We were reading it
   as a UTF-8 string, then converting it back to a buffer, then
   re-reading that buffer as a UTF-8 string.)
4. Small: don't keep useless references around.
@EvanHahn EvanHahn force-pushed the speed-up-email-renderer branch from a3b8016 to fc6f56a Compare March 18, 2026 14:36
@EvanHahn EvanHahn requested a review from 9larsons March 18, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok to merge for me You can merge this on my behalf if you want.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants