fix: honor byteOffset when deserializing L2 coordinate cache (Node Buffer) — v0.7.1#9
Merged
Conversation
…ffer) bytesToFloat64 rebuilt the Float64Array via bytes.slice(0,n).buffer + new Float64Array(buffer, 0, ...), reading from offset 0 of the underlying ArrayBuffer. For a Node Buffer (ioredis getBuffer pools Buffers as views with a non-zero byteOffset) this read the wrong bytes, corrupting any coordinate/time array served from the shared coordinateCache. A garbled, non-ascending time axis then collapsed downstream time-window lookups so every series point folded onto one timestamp. Copy the view's own byte range with ArrayBuffer.prototype.slice, honoring byteOffset. Add a regression test exercising a pooled-Buffer round-trip. Release v0.7.1.
brandao-andre
approved these changes
Jun 15, 2026
brandao-andre
approved these changes
Jun 15, 2026
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.
Problem
Coordinate/time arrays served from the shared L2
coordinateCache(ManagedDataset.decodedArray) came back corrupted whenever the cache returned a NodeBuffer.bytesToFloat64rebuilt theFloat64Arrayvia:ioredis
getBuffercarves Buffers from a shared pool, so the returnedBufferis a view with a non-zerobyteOffset. Reading from offset 0 of the underlyingArrayBuffer(ignoringbyteOffset) returns shifted/garbage values.Downstream impact (observed in nautilus-api compare-models)
A garbled, non-ascending decoded time axis broke
timeWindow's binary search → the requested window collapsed to the full range with a single repeated timestamp. Every series point rendered with the same timestamp. Same corruption silently affected lat/lon coordinate arrays (nearest-point resolution). Only manifested once the L2 cache was populated (first read = L2 miss = correct), which is why it looked like "just cache".Fix
Copy the view's own byte range with
ArrayBuffer.prototype.slice, honoringbyteOffset:Robust for plain
Uint8Arrayviews and pooled NodeBuffers alike.Tests
dataset-registry.test.tsthat serves L2 through a cache returning a pooled NodeBuffer(non-zerobyteOffset). Fails on the old code ([0, 10, 20]shifted), passes with the fix.prepublishOnlychain (typecheck/lint/test/build/validate-exports/cjs/esm interop) green.Release
Bumps to 0.7.1 + CHANGELOG entry. After merge, tag
v0.7.1to trigger the publish workflow.