Skip to content

fix: isolate large array options per serializer - #877

Closed
lprnmns wants to merge 2 commits into
fastify:mainfrom
lprnmns:fix/isolate-large-array-options-20260829-human-dco
Closed

lprnmns wants to merge 2 commits into
fastify:mainfrom
lprnmns:fix/isolate-large-array-options-20260829-human-dco

Conversation

@lprnmns

@lprnmns lprnmns commented Aug 31, 2026

Copy link
Copy Markdown

Problem

The large-array options are applied to module-level state, so building one customized serializer changes the behavior of later serializers that omit those options.

For example, after building with largeArrayMechanism: 'json-stringify' and largeArraySize: 1, a later default serializer uses JSON.stringify for a one-element integer array and throws on a BigInt. The default serializer normally handles that BigInt as documented.

Fix

Keep largeArrayMechanism and largeArraySize in the per-build context used during code generation. Explicit options remain unchanged, while each build starts with the documented defaults.

Tests

  • node --test --test-name-pattern='large-array options do not leak between serializers' test/array.test.js - passed; the same regression failed before the fix
  • npm test - passed; 502 unit tests, 100% reported coverage, 13 TypeScript assertions
  • npm run lint - passed
  • npm run benchmark - passed
  • node --check index.js && node --check test/array.test.js - passed
  • git diff --check - passed

Compatibility

An individual serializer's explicit large-array settings are unchanged. Serializers built without options no longer inherit settings from an earlier build. No package version or lockfile was changed.

Related issue

Independent reproduction; no current issue or open PR matching per-build large-array option isolation was found.

Signed-off-by: lprnmns <manasalperen@gmail.com>
@lprnmns
lprnmns marked this pull request as ready for review August 31, 2026 16:18
Signed-off-by: lprnmns <manasalperen@gmail.com>
@Tony133

Tony133 commented Oct 20, 2026

Copy link
Copy Markdown
Member

Thank you for the contribution and the clear write-up. This was fixed by #899 (v7.1.1), which moves largeArrayMechanism and largeArraySize onto the per-build context in the same way, so the options no longer carry over between builds on main. Closing as fixed by #899.

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