-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypedArrays are not spec-compliant and break Buffer with many ecosystem packages #1495
Comments
Thank you for the detailed and well-researched bug report. We appreciate the effort you put into diagnosing the issue and linking to the relevant sections of the ECMAScript specification. To provide some context, the behavior you're observing is actually by design in Hermes. As documented in our Excluded from Support section, we deliberately do not support Supporting this would require introducing a slow path in every case where a new object is returned that doesn't match the expected type. That would add a ton of complexity for a use case that didn't seem very important. Frankly, we didn't realize the importance of this for implementing something I wonder whether it would be sufficient, as an intermediate step, to only support the case where |
@tmikov this is not about
Unsupported The testcase doesn't use |
Ah, haven't noticed that! This breaks a lot of things though in a subtle unexpected way
Unsure A previous Buffer version relied on |
@ChALkeR so, it appears the intermediate step we proposed is the actual spec-compliant behavior of TypedArray. That is fortunate. We will implement at least the partial support through |
|
|
In that taxonomy:
I'm not sure if it's worth to add |
I agree that Type 2 is unlikely to be removable. |
Bug Description
See explainer, test and a monkey-patch fix at https://github.com/ExodusMovement/patch-broken-hermes-typed-arrays
Sections of specification broken in Hermes:
%TypedArray%.prototype.subarray
%TypedArray%.prototype.map
%TypedArray%.prototype.filter
%TypedArray%.prototype.slice
See https://github.com/ExodusMovement/patch-broken-hermes-typed-arrays/blob/main/index.js for links to specific spec steps
See ecosystem fallout in feross/buffer#329
have runconfirmed this bug does not occur with JSCgradle clean
andReact Native.HermesHermes git revision (if applicable): 0410fb4 (latest
main
)React Native version: 🤷🏻
OS:
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
Steps To Reproduce
See full explainer, test and a monkey-patch fix at https://github.com/ExodusMovement/patch-broken-hermes-typed-arrays
The Expected Behavior
Implementation of TypedArray per spec, perhaps without
Symbol.species
but with working inheritanceSee spec refs above
The text was updated successfully, but these errors were encountered: