Fix RemoteNodeList inherited array methods throwing this.view.getUint32 is not a function#4346
Open
Copilot wants to merge 3 commits into
Open
Fix RemoteNodeList inherited array methods throwing this.view.getUint32 is not a function#4346Copilot wants to merge 3 commits into
this.view.getUint32 is not a function#4346Copilot wants to merge 3 commits into
Conversation
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix RemoteNodeList inherited array methods throwing an error
Fix RemoteNodeList inherited array methods throwing Jun 17, 2026
this.view.getUint32 is not a function
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a runtime error in the native preview API where RemoteNodeList (which subclasses Array) would throw when calling inherited array methods (e.g. filter/map/slice) due to ArraySpeciesCreate constructing new RemoteNodeList(length).
Changes:
- Update the encoder generator to emit
static get [Symbol.species]()onRemoteNodeList, forcing derived array methods to return plainArrayinstances. - Regenerate
node.generated.tsto include the newSymbol.speciesoverride. - Add a sync regression test covering
filter/map/sliceonRemoteNodeList.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| _scripts/generate-encoder.ts | Emits a RemoteNodeList Symbol.species override so inherited array methods don’t invoke the custom constructor. |
| _packages/native-preview/src/api/node/node.generated.ts | Generated output reflecting the new Symbol.species override in RemoteNodeList. |
| _packages/native-preview/test/sync/ast.test.ts | Adds a regression test ensuring array methods no longer throw on RemoteNodeList. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
andrewbranch
approved these changes
Jun 17, 2026
4 tasks
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.
NodeArray<T>(exposed via the native API) extendsReadonlyArray<T>, but calling inherited array methods on aRemoteNodeList(e.g.sourceFile.statements.filter(...),.map(...),.slice(...)) threwTypeError: this.view.getUint32 is not a function.Root cause
RemoteNodeList extends Array<RemoteNode>. Inherited methods likefilter/map/sliceuseArraySpeciesCreate, which constructs the result vianew this.constructor[Symbol.species](length). The default species isRemoteNodeList, so this invokednew RemoteNodeList(length)— passing a number where aDataViewis expected. The constructor then runsthis.length = this.data, dereferencingthis.view.getUint32(...)on a number.Changes
_scripts/generate-encoder.ts: Emit astatic get [Symbol.species]()returningArrayonRemoteNodeList, so inherited array methods produce plain arrays instead of reconstructing aRemoteNodeList.node.generated.ts: Regenerated output (verified identical to the generator emission).test/sync/ast.test.ts: Regression test coveringfilter/map/slice.The new test fails with the reported error prior to the change and passes after.