Repository navigation
feat: document and test the objectMechanism option of fast-json-stringify v7.3.0 - #102
Merged
Merged
Conversation
Tony133
marked this pull request as ready for review
November 5, 2026 16:32
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.
Proposal:
Follow-up to fastify/fast-json-stringify#906, as discussed there and in fastify/fastify#6507.
Context:
fast-json-stringify@7.3.0addedobjectMechanism: 'native': the serializer projects the payload into schema-shaped objects and delegates toJSON.stringify, so on Node.js 25+ V8 stays on its fast path while the response schema is still applied. Output is identical to the default mechanism; the option is a no-op on Node.js < 25.Change:
The compiler already forwards
serializerOptsas-is, and the types importOptionsfromfast-json-stringify, so nothing in the code needs to change. This PR makes the option usable and visible:fast-json-stringifydependency bumped to^7.3.0, soobjectMechanismis accepted and typed;serializerOpts: { objectMechanism: 'native' }example;objectMechanismthrows through the compiler (proves the option reachesfast-json-stringifyon every runtime),'native'and'default'give the same output on an input carrying an undeclared property and aDate, and a Fastify integration test withserializerOpts: { objectMechanism: 'native' };'native'and'default'accepted, an arbitrary string rejected.Why now:
This is the first step towards proposing
'native'as the default in Fastify v6; it lets users opt in on v5 today.Note:
fast-json-stringify@^7.3.0and documents a new option, so it should go out as a minor release (semver-minor).min-release-age=7rejectsfast-json-stringify@7.3.0until Nov 12. The second commit temporarily excludes it from the check (min-release-age-exclude, npm >= 11.17), with a dated comment in.npmrc; I'll remove those two lines after the 12th, or drop the commit now if you'd rather wait.