Repository navigation
Fixed Date values being cloned to {} in prepareStackForUser - #1046
Merged
Merged
Conversation
prepareStackForUser deep clones the error before Ghost renders it, and the inline deepCloneValue that replaced @stdlib/utils-copy in a447d77 copied every non-array object as a plain object. Date has no own enumerable keys, so any Date in errorDetails or context came out as {}. UpdateCollisionError from @tryghost/bookshelf-collision carries clientUpdatedAt and serverUpdatedAt as Dates, so every 409 response from Ghost's API has returned both as {}. Admin reports these collisions to Sentry to tell a concurrent writer apart from a retried save, which needs the timestamps. Dates are now cloned as Dates, so they serialize to ISO strings again.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1046 +/- ##
==========================================
+ Coverage 97.91% 98.19% +0.27%
==========================================
Files 92 47 -45
Lines 3122 1939 -1183
Branches 550 372 -178
==========================================
- Hits 3057 1904 -1153
+ Misses 23 10 -13
+ Partials 42 25 -17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9larsons
added a commit
to TryGhost/Ghost
that referenced
this pull request
Oct 9, 2026
ref TryGhost/framework#1046 Since @tryghost/errors 3.0.1 replaced @stdlib/utils-copy with an inline clone, prepareStackForUser turned any Date in errorDetails into {}. Every 409 UpdateCollisionError from the Admin API therefore returned clientUpdatedAt and serverUpdatedAt as {}, which leaves the editor's Sentry collision reports unable to tell a concurrent writer apart from a retried save. 3.4.2 clones Dates as Dates, so both fields serialize to ISO strings again.
9larsons
added a commit
to TryGhost/Ghost
that referenced
this pull request
Oct 9, 2026
ref TryGhost/framework#1046 Picks up @tryghost/errors 3.4.2 and the framework patch releases that came with it. Since @tryghost/errors 3.0.1 replaced @stdlib/utils-copy with an inline clone, prepareStackForUser turned any Date in errorDetails into {}. Every 409 UpdateCollisionError from the Admin API therefore returned clientUpdatedAt and serverUpdatedAt as {}, which leaves the editor's Sentry collision reports unable to tell a concurrent writer apart from a retried save. 3.4.2 clones Dates as Dates, so both fields serialize to ISO strings again. The other framework packages only pick up the new @tryghost/errors.
9larsons
added a commit
to TryGhost/Ghost
that referenced
this pull request
Oct 9, 2026
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.
prepareStackForUserdeep clones the error before Ghost renders it. The inlinedeepCloneValuethat replaced@stdlib/utils-copyin a447d77 (#426) copies every non-array object as a plain object. ADatehas no own enumerable keys, so any Date inerrorDetailsorcontextcame out as{}.UpdateCollisionErrorfrom@tryghost/bookshelf-collisionputsclientUpdatedAtandserverUpdatedAtinerrorDetailsas Dates. As a result, every 409 collision response from Ghost's API has returned both as{}. Admin reports these collisions to Sentry to tell a concurrent writer apart from a retried save, and it needs the timestamps to do that.deepCloneValuenow clones a Date as a new Date with the same time, so it serializes to an ISO string again.Scope: Buffer, typed arrays, Map, Set and RegExp were also preserved by
@stdlib/utils-copy. They're left out because nothing in Ghost core puts them inerrorDetails. Map, Set and RegExp also serialize to{}in JSON either way.After release, Ghost needs its
@tryghost/errorscatalog pin inpnpm-workspace.yamlbumped from 3.4.1.Test: a Date nested in
errorDetailssurvivesprepareStackForUseras a separate Date with equal time, and a JSON round trip gives the ISO string. The test fails without the fix.