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

MMM + SES: Uncaught exceptions (2) ethjs #20

Open
leotm opened this issue Jun 9, 2023 · 0 comments
Open

MMM + SES: Uncaught exceptions (2) ethjs #20

leotm opened this issue Jun 9, 2023 · 0 comments

Comments

@leotm
Copy link
Member

leotm commented Jun 9, 2023

Up-to-date follow-up to

reproducer

modules

  • node_modules/ethjs/node_modules/ethjs-query/lib/index.js
  • node_modules/ethjs/node_modules/ethjs-contract/lib/index.js

cause

TypeError: Cannot assign to read only property 'constructor' of object '[object Object]'
Error: Requiring module "node_modules/ethjs/node_modules/ethjs-query/lib/index.js", which threw an exception: TypeError: Cannot assign to read only property 'constructor' of object '[object Object]'
TypeError: _$$_REQUIRE(...) is not a constructor
TypeError: Cannot read properties of undefined (reading 'tokenList')
SES_UNHANDLED_REJECTION: 

causing 2 uncaught promise rejection exceptions

node_modules/ethjs/lib/index.js
1 uncaught exception: Paused on promise rejection
Exception: TypeError “_$$_REQUIRE(...) is not a constructor”
var query = new EthQuery(cprovider, self.options.query);

Screenshot 2023-05-26 at 13 13 46 2 uncaught exception: paused on promise rejection Caught: TypeError "Cannot read properties of undefined (reading 'PreferencesController')" node_modules/@babel/runtime/helpers/asyncToGenerator.js

3 (x4)

Screenshot 2023-05-26 at 13 22 32

node_modules/metro-runtime/src/polyfills/require.js
function metroRequire(moduleId) { … }
modules processed pre/during SES repairing intrinsics

Screenshot 2023-05-26 at 17 49 11

Simulator Screen Shot - iPhone 12 Pro - 2023-06-07 at 17 30 42

first seen in

  • MMM: RN 0.66.5 + SES 0.18.4
@leotm leotm added the promise Promise polyfill label Jul 12, 2023
@leotm leotm changed the title RN 0.66.5 + SES 0.18.4: Uncaught exceptions (2) ethjs MMM + SES: Uncaught exceptions (2) ethjs Aug 17, 2023
leotm added a commit to MetaMask/metamask-mobile that referenced this issue Jan 23, 2024
## **Description**

Fix recent spike in iOS crashes (sending ETH on Optimism)
and reenable SES on iOS (we disabled it temporarily for our v7.12.2
hotfix)
_nb: [flakey CI](#8046)
earlier was Node 18.19, not SES_

Make `[email protected]` compatible with SES via a
[patch](c5eba9d)
(updated since to a resolution)
- refactor generator function prototype iterator symbol
- update object property assignment to `Object.defineProperty`

```console
...
├─┬ @metamask/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
...
```

<details><summary>full regenerator-runtime dep tree</summary>

```console
├─┬ @babel/[email protected]
│ └── [email protected]
├─┬ @metamask/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
├─┬ @storybook/[email protected]
│ └─┬ @storybook/[email protected]
│   └── [email protected] deduped
├─┬ @storybook/[email protected]
│ └─┬ @storybook/[email protected]
│   ├─┬ @storybook/[email protected]
│   │ └── [email protected] deduped
│   ├─┬ @storybook/[email protected]
│   │ └── [email protected]
│   ├─┬ @storybook/[email protected]
│   │ └── [email protected] deduped
│   └── [email protected]
├─┬ @storybook/[email protected]
│ ├─┬ @storybook/[email protected]
│ │ ├─┬ @storybook/[email protected]
│ │ │ └── [email protected]
│ │ └── [email protected]
│ ├─┬ @storybook/[email protected]
│ │ ├─┬ @storybook/[email protected]
│ │ │ ├─┬ @storybook/[email protected]
│ │ │ │ └── [email protected] deduped
│ │ │ ├─┬ @storybook/[email protected]
│ │ │ │ └── [email protected] deduped
│ │ │ ├─┬ @storybook/[email protected]
│ │ │ │ └── [email protected] deduped
│ │ │ └── [email protected]
│ │ └── [email protected]
│ └─┬ @storybook/[email protected]
│   └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │   ├─┬ @jimp/[email protected]
│ │   │ └─┬ @jimp/[email protected]
│ │   │   └─┬ @jimp/[email protected]
│ │   │     └── [email protected]
│ │   └── [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └─┬ @babel/[email protected]
│       └── [email protected]
├─┬ [email protected] invalid: "^0.0.0-0 || 0.60 - 0.70 || 1000.0.0" from node_modules/@react-native-async-storage/async-storage, "^0.56.0" from node_modules/react-native-jazzicon, "^0.62.2" from node_modules/react-native-v8
│ └── [email protected]
└── [email protected]
```

</details>

Considerations
- further patch `runtime.js` other relevant parts
- or resolve
`@metamask/assets-controllers>babel-runtime>regenerator-runtime`
- from v0.11.1 to v0.13.8+ (containing
[fix](facebook/regenerator@903a507))
- or resolve `@metamask/assets-controllers>babel-runtime`
- from v6.26.0 to
[v7.8.4](https://github.com/babel/babel/blame/9015fda3c106abda6928cf348797a38f09d4b3e0/packages/babel-runtime/package.json)+
(regenerator-runtime: ^0.13.2, which locks to 0.13.11)
- [ethjs patches](LavaMoat/docs#20) still
needed?

_Remaining `regenerator-runtime` transitive deps are safe above v0.13.8
(see dep tree above)_

## **Related issues**

Fixes: #8015

- https://metamask.sentry.io/issues/4699573603/?project=2299799 sev1
  - _app/lib/ens-ipfs/resolver.js26:42_ in `resolveEnsToIpfsContentId`
- `const Registry = contract(registryAbi).at(registryAddress);` an
ethjs/ethjs-contract
- _Suspect Commit:
b677fd9
update to `resolveEnsToIpfsContentId`_
- https://metamask.sentry.io/issues/4701946024/?project=2299799

<img width="661" alt="Screenshot 2023-12-07 at 4 03 00 pm"
src="https://github.com/MetaMask/metamask-mobile/assets/1881059/d92afd9d-ba11-453c-a8ad-fae043dd79d0">

Fixes: #8017

- https://metamask.sentry.io/issues/4702324986/?project=2299799

Additional context
- MetaMask/metamask-extension#10663
- endojs/endo#1855

## **Manual testing steps**

Steps in Sentry issue breadcrumbs (iOS prod)

To enable SES in debug-mode, omit `!__DEV__`


https://github.com/MetaMask/metamask-mobile/blob/46c1cea9328ff2a71bbbe98179af755c56385fd3/patches/react-native%2B0.71.14.patch#L11-L12

_I've not managed to repro locally this way yet_

## **Screenshots/Recordings**

### **Before**

### **After**

## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained what problem this PR is solving and how it
is solved.
- [x] I've linked related issues
- [x] I've included manual testing steps
- [x] I've included screenshots/recordings if applicable
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [x] I’ve properly set the pull request status:
  - [x] In case it's not yet "ready for review", I've set it to "draft".
- [x] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: Cal Leung <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant