Skip to content

fix: isolate large array options per serializer - #877

Open
lprnmns wants to merge 1 commit into
fastify:mainfrom
lprnmns:fix/isolate-large-array-options-20260829-human-dco
Open

fix: isolate large array options per serializer#877
lprnmns wants to merge 1 commit 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
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.

1 participant