Skip to content

Skipped unnecessary serialization of previous value in webhooks - #29166

Merged
EvanHahn merged 1 commit into
mainfrom
skip-unnecessary-serialization-of-previous-value-in-webhooks
Jul 9, 2026
Merged

Skipped unnecessary serialization of previous value in webhooks#29166
EvanHahn merged 1 commit into
mainfrom
skip-unnecessary-serialization-of-previous-value-in-webhooks

Conversation

@EvanHahn

@EvanHahn EvanHahn commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

no ref

This performance improvement should have no user impact.

Webhook payloads have a previous value, which is the old state of the model. This only includes keys that have changed.

Before this change, we'd compute it and then, sometimes, discard everything.

After this change, we only compute it if there's anything to compute.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 64464245-4ae6-4e47-835d-9681cbc021bc

📥 Commits

Reviewing files that changed from the base of the PR and between 9bcfdd2 and adaa034.

📒 Files selected for processing (1)
  • ghost/core/core/server/services/webhooks/serialize.js

Walkthrough

The webhook serializer in serialize.js now computes a changed field list early from model._changed. The previous snapshot is generated only when changed is non-empty and model._previousAttributes exists. The serialized previous document state is filtered to only changed properties at the point of assignment, and the resulting webhook payload directly embeds this pre-filtered previous snapshot instead of filtering the full previous state during payload construction.

Possibly related PRs

  • TryGhost/Ghost#29162: Modifies the same serialize.js file to compute changed from model._changed and filter the previous webhook payload to changed fields.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main webhook serialization optimization.
Description check ✅ Passed The description aligns with the changeset and explains the same webhook previous-value optimization.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 skip-unnecessary-serialization-of-previous-value-in-webhooks

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.

@nx-cloud

nx-cloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit adaa034

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 50s View ↗
nx run ghost:test:integration ✅ Succeeded 2m 58s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 58s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 38s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run-many -t lint -p ghost ✅ Succeeded 35s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 28s View ↗
nx run @tryghost/admin:build ✅ Succeeded 6s View ↗
Additional runs (2) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-09 16:06:13 UTC

no ref

This performance improvement should have no user impact.

Webhook payloads have a `previous` value, which is the old state of the
model. This only includes keys that have changed.

Before this change, we'd compute it and then, sometimes, discard
everything.

After this change, we only compute it if there's anything to compute.
@EvanHahn
EvanHahn marked this pull request as ready for review July 9, 2026 15:54

const payload = {
[docName.replace(/s$/, '')]: {
current: current,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Minor: I only changed this line for consistency.

@EvanHahn
EvanHahn force-pushed the skip-unnecessary-serialization-of-previous-value-in-webhooks branch from 54303c4 to adaa034 Compare July 9, 2026 15:55
@EvanHahn
EvanHahn requested a review from kevinansfield July 9, 2026 18:47
@EvanHahn
EvanHahn merged commit a0db086 into main Jul 9, 2026
44 checks passed
@EvanHahn
EvanHahn deleted the skip-unnecessary-serialization-of-previous-value-in-webhooks branch July 9, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants