Skip to content
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

feat(ses): fix undefined AsyncGenerator prototype on Hermes #2220

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/ses/src/get-anonymous-intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,18 @@ export const getAnonymousIntrinsics = () => {

// 25.3.2.2 AsyncGeneratorFunction.prototype
const AsyncGenerator = AsyncGeneratorFunction.prototype;

const asyncIterable = {
// eslint-disable-next-line no-restricted-globals, no-empty-function
async *[Symbol.asyncIterator]() {},
};

// eslint-disable-next-line @endo/no-polymorphic-call, no-restricted-globals
const asyncIterator = asyncIterable[Symbol.asyncIterator]();

// 25.5.1 Properties of the AsyncGenerator Prototype Object
const AsyncGeneratorPrototype = AsyncGenerator.prototype;
const AsyncIteratorPrototype = getPrototypeOf(AsyncGeneratorPrototype);
const AsyncGeneratorPrototype = AsyncGenerator.prototype; // undefined on Hermes
const AsyncIteratorPrototype = getPrototypeOf(asyncIterator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be sufficient to do

Suggested change
const AsyncIteratorPrototype = getPrototypeOf(asyncIterator);
const AsyncIteratorPrototype = getPrototypeOf(AsyncGeneratorFunctionInstance());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's likely. Worth testing if it falls into the category of what Hermes supports, but looks equivalent to what we've tried here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the suggestion works too ^ but still causes the test to fail, i've looked into it here #2220 (comment) if any thoughts


// 25.7.1 The AsyncFunction Constructor

Expand Down
Loading