Skip to content

Partial async generator support present in Hermes isn't spec compliant #1380

@leotm

Description

@leotm

Bug Description

  • I have run gradle clean and confirmed this bug does not occur with JSC
  • The issue is reproducible with the latest version of React Native.

Hermes git revision (if applicable): hermes-2023-03-07-RNv0.71.4-ee25883ea34374f687883a641c8101ac0d292fc6
React Native version: 71.17
OS: Android (running on macOS)
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): arm64-v8a

Steps To Reproduce

Attempt to access async iterator proto

code example:

async function* AsyncGeneratorFunctionInstance() {}
const AsyncGeneratorFunction = Object.getPrototypeOf(
  AsyncGeneratorFunctionInstance,
).constructor
const AsyncGenerator = AsyncGeneratorFunction.prototype;

const asyncIterable = {
  async *[Symbol.asyncIterator]() {},
};
var results = [
  typeof asyncIterable[Symbol.asyncIterator].prototype.__proto__ === 'object', // it's an object even in Hermes, but looks a different shape
  typeof AsyncGenerator.prototype, // undefined on hermes
  asyncIterable[Symbol.asyncIterator].prototype.__proto__ === AsyncGenerator.prototype, // true in other engines
  asyncIterable[Symbol.asyncIterator].prototype.__proto__.__proto__ // null in Hermes, object with an iterator fn in other engines
];

// Node 18.18.2
// console.log(Object.getOwnPropertyDescriptors(asyncIterable[Symbol.asyncIterator].prototype.__proto__.__proto__))
// {
//   [Symbol(Symbol.asyncIterator)]: {
//     value: [Function: [Symbol.asyncIterator]],
//     writable: true,
//     enumerable: false,
//     configurable: true
//   }
// }

throw JSON.stringify(results);

The Expected Behavior

Other engines: [true,"object",true,{}]
Hermes: [true,"undefined",false,null]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions