Skip to content

fix(typed-array): serialize non-finite floating-point values - #73

Merged
BridgeAR merged 2 commits into
mainfrom
BridgeAR/2026-10-13-typed-array-finite-values
Oct 13, 2026
Merged

BridgeAR merged 2 commits into
mainfrom
BridgeAR/2026-10-13-typed-array-finite-values

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Floating typed arrays bypass number normalization in the optimized paths, so NaN and infinities produce invalid JSON and escape strict-mode rejection.

The maintainer changes restrict finite checks to floating-point arrays and run them inline, preserving direct conversion for integer and BigInt arrays.

On Node 24.20.0 (V8 13.6.233.17-node.53), CPU time per call falls from 4.92 to 4.11 µs against the contributor commit for 128 indented Int32Array values. For 128 compact Float64Array values, it falls from 8.27 to 7.54 µs. These means use two fresh processes with 50k warmup calls and seven trials per shape, excluding the extremes.

Closes: #69
Fixes: #68

feritcemkahraman and others added 2 commits October 13, 2026 12:45
A formatter closure adds finite checks to integer arrays and an extra call for floating-point values. Inline checks retain direct conversion for integer and BigInt arrays.

On Node 24.20.0 (V8 13.6.233.17-node.53), CPU time per call falls from 4.92 to 4.11 µs for 128 indented Int32Array values. For 128 compact Float64Array values, it falls from 8.27 to 7.54 µs. These means use two fresh processes with 50k warmup calls and seven trials per shape, excluding the extremes.

Refs: #69
@BridgeAR
BridgeAR marked this pull request as ready for review October 13, 2026 04:21
@BridgeAR
BridgeAR merged commit 25b3110 into main Oct 13, 2026
5 checks passed
@BridgeAR
BridgeAR deleted the BridgeAR/2026-10-13-typed-array-finite-values branch October 13, 2026 04:23
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.

TypedArray with NaN/Infinity produces invalid JSON (and strict doesn't catch it)

2 participants