Skip to content

feat: support Array<ArrayBuffer> as a TurboModule method parameter - #58029

Open
paradowstack wants to merge 2 commits into
react:mainfrom
paradowstack:feat/codegen-array-of-arraybuffer
Open

feat: support Array<ArrayBuffer> as a TurboModule method parameter#58029
paradowstack wants to merge 2 commits into
react:mainfrom
paradowstack:feat/codegen-array-of-arraybuffer

Conversation

@paradowstack

@paradowstack paradowstack commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Rebase Note:

This branch is stacked on #57937 (Promise<ArrayBuffer> for Java/ObjC TurboModules) and must be rebased onto main once that lands. For now review only the last commit.

Summary:

TurboModules could take a single ArrayBuffer, but not a list of them. Array<ArrayBuffer> fell through to the generic array path and degraded silently to ReadableArray / NSArray, so the buffers arrived as untyped array elements rather than as buffers.

This adds Array<ArrayBuffer> as a top-level method parameter. Codegen emits ArrayBuffer[] for the Java spec, [Lcom/facebook/react/bridge/ArrayBuffer; for the JNI signature, and NSArray<RCTArrayBuffer *> * for ObjC.

Every other position — nested arrays, object properties, return types, Promise resolutions, callback parameters and returns, and event emitter payloads — now throws at codegen time instead of degrading silently, so a spec cannot compile into something that quietly loses its buffers. C++ TurboModules (cxxOnly) deliberately skip the guard: Array<ArrayBuffer> degrades to a plain jsi::Array there, which is the right shape for a module that already works on raw JSI.

Nullable elements are not supported. Array<?ArrayBuffer> throws at codegen time, and the generators fall back to an untyped array if the guard is ever bypassed. Neither platform can honour it: an NSArray cannot hold nil, so iOS would have to deliver NSNull inside an array whose lightweight generic promises RCTArrayBuffer *, and RN's Java codegen emits javax.annotation.Nullable, which is declaration-only and cannot annotate an array's element type.

Changelog:

[GENERAL] [ADDED] - Support Array<ArrayBuffer> as a TurboModule method parameter

Test Plan:

  • error-utils-test covers throwIfUnsupportedArrayBufferArrayUsage and its event emitter counterpart.
  • Java spec, JNI C++, ObjC header, .mm and C++ spec snapshots updated.
  • RCTTurboModuleArrayBufferTests.mm adds five new tests.
  • SampleTurboModule / RCTSampleTurboModule add arrayBufferArray.
  • C++ API snapshots regenerated.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 20, 2026
@paradowstack
paradowstack force-pushed the feat/codegen-array-of-arraybuffer branch from d9c6943 to 26c2724 Compare August 20, 2026 13:20
@paradowstack
paradowstack force-pushed the feat/codegen-array-of-arraybuffer branch from 26c2724 to 9ffa67b Compare August 20, 2026 13:54
@paradowstack
paradowstack marked this pull request as ready for review August 20, 2026 14:08
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 20, 2026
@paradowstack
paradowstack force-pushed the feat/codegen-array-of-arraybuffer branch from 9ffa67b to 127c367 Compare August 21, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant