Skip to content

fix: keep the large array options on the build instead of the module - #881

Closed
nigrosimone wants to merge 1 commit into
fastify:mainfrom
nigrosimone:fix-large-array-state
Closed

nigrosimone wants to merge 1 commit into
fastify:mainfrom
nigrosimone:fix-large-array-state

Conversation

@nigrosimone

Copy link
Copy Markdown
Contributor

largeArrayMechanism and largeArraySize are module-level variables that build overwrites when the options are given and never resets. After fastJson(schema, { largeArrayMechanism: 'json-stringify', largeArraySize: 3 }), every later fastJson(otherSchema) without those options serializes arrays of 3 or more items through JSON.stringify, which drops the item schema: a date formatted array comes out with full ISO strings.

The fix keeps both on the build context, with the defaults applied on every build.

The added test builds once with the options and once without, on the same schema, and checks the second one formats the dates: it fails on main and passes here.

@nigrosimone
nigrosimone marked this pull request as ready for review September 13, 2026 11:24
@Tony133

Tony133 commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Closing as superseded by #899, which makes the large-array options local to each build() call instead of module-wide. The format: 'date' regression test from this PR fails on the commit right before #899 and passes on current main, so the fix is already in. Thanks for the contribution!

@Tony133 Tony133 closed this Oct 18, 2026
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