Skip to content

fix(core): TextDecoder decodes only the bytes of a typed array view - #11578

Merged
NathanWalker merged 1 commit into
mainfrom
fix/text-decoder-view-range
Oct 28, 2026
Merged

NathanWalker merged 1 commit into
mainfrom
fix/text-decoder-view-range

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

TextDecoder.decode() turns a typed array or DataView into new Uint8Array(input.buffer), which is the view's entire underlying ArrayBuffer. A view that covers only part of a buffer, such as a subarray(), a Buffer slice, or a pooled buffer, therefore also decodes the bytes outside the view. That's what breaks cbor and libp2p decoding in #9941.

What is the new behavior?

For views, the decoder reads exactly byteOffset..byteOffset + byteLength. Plain ArrayBuffer input and the existing type check don't change.

The new spec text/text-common.spec.ts covers ArrayBuffer, subarray and DataView ranges, a multi-byte round trip through TextEncoder, and the non-buffer rejection. The two view-range cases fail without the fix. The full core suite passes (556 tests).

Closes #9941.

@nx-cloud

nx-cloud Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit fe56a60

Command Status Duration Result
nx run-many -t build -p core,webpack5,vite ✅ Succeeded 23s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-23 20:05:08 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11578
npm i https://pkg.pr.new/@nativescript/vite@11578
npm i https://pkg.pr.new/@nativescript/webpack@11578

commit: fe56a60

@NathanWalker
NathanWalker merged commit 24c8311 into main Oct 28, 2026
10 checks passed
@NathanWalker
NathanWalker deleted the fix/text-decoder-view-range branch October 28, 2026 16:41
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.

Strange behavior when using TextDecoder

1 participant