Skip to content

Commit

Permalink
refactor(ses): document Hermes bugs and fixes for intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
leotm committed Oct 24, 2024
1 parent 2b0b560 commit 575cd60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/ses/src/intrinsics.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ export const makeIntrinsicsCollector = () => {
}
const permitPrototype = permit.prototype;

// Bypass Hermes bug, fixed in: https://github.com/facebook/hermes/commit/00f18c89c720e1c34592bb85a1a8d311e6e99599
if (
typeof intrinsic === 'function' &&
intrinsic.prototype !== undefined &&
permitPrototype === 'undefined' // permits.js
) {
// Set intrinsics that are additional function properties of the global Object proposed by SES to have non-standard prototype properties set to undefined.
// Set Hermes additional function intrinsics proposed by SES containing non-standard prototypes to undefined.
// This includes arrow functions (lockdown and harden) and object literal methods (%InitialGetStackString%).
intrinsic.prototype = undefined;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/ses/src/permits.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ export const AsyncFunctionInstance = {

// Aliases
const fn = FunctionInstance;
const hermesFn = { ...FunctionInstance, prototype: 'undefined' }; // Bypass Hermes bug, fixed in: https://github.com/facebook/hermes/commit/00f18c89c720e1c34592bb85a1a8d311e6e99599
// Bypass Hermes bugs, fixed in:
// - https://github.com/facebook/hermes/commit/c42491de94aff479e5e83c073eff96a6261da080
// - https://github.com/facebook/hermes/commit/00f18c89c720e1c34592bb85a1a8d311e6e99599
// Expect additional Function Properties of the Global Object proposed by SES to have non-standard prototype properties set to undefined.
// This includes arrow functions (lockdown and harden) and object literal methods (%InitialGetStackString%).
const hermesFn = { ...FunctionInstance, prototype: 'undefined' };
const asyncFn = AsyncFunctionInstance;

const getter = {
Expand Down

0 comments on commit 575cd60

Please sign in to comment.