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

fix: regenerator-runtime and reenable SES (v1.1.0) on iOS (JSC) #8033

Merged
merged 16 commits into from
Jan 23, 2024

Conversation

leotm
Copy link
Member

@leotm leotm commented Dec 7, 2023

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 earlier was Node 18.19, not SES

Make regenerator-runtime@0.11.1 compatible with SES via a patch (updated since to a resolution)

  • refactor generator function prototype iterator symbol
  • update object property assignment to Object.defineProperty
...
├─┬ @metamask/assets-controllers@7.0.0
│ └─┬ babel-runtime@6.26.0
│   └── regenerator-runtime@0.11.1
...
full regenerator-runtime dep tree
├─┬ @babel/runtime@7.23.2
│ └── regenerator-runtime@0.14.0
├─┬ @metamask/assets-controllers@7.0.0
│ └─┬ babel-runtime@6.26.0
│   └── regenerator-runtime@0.11.1
├─┬ @storybook/addon-knobs@5.3.21
│ └─┬ @storybook/api@5.3.21
│   └── regenerator-runtime@0.13.9 deduped
├─┬ @storybook/addon-ondevice-actions@6.5.6
│ └─┬ @storybook/addons@6.5.16
│   ├─┬ @storybook/api@6.5.16
│   │ └── regenerator-runtime@0.13.11 deduped
│   ├─┬ @storybook/router@6.5.16
│   │ └── regenerator-runtime@0.13.11
│   ├─┬ @storybook/theming@6.5.16
│   │ └── regenerator-runtime@0.13.11 deduped
│   └── regenerator-runtime@0.13.11
├─┬ @storybook/react-native@6.5.6
│ ├─┬ @storybook/client-api@6.5.16
│ │ ├─┬ @storybook/store@6.5.16
│ │ │ └── regenerator-runtime@0.13.11
│ │ └── regenerator-runtime@0.13.11
│ ├─┬ @storybook/core-client@6.5.16
│ │ ├─┬ @storybook/ui@6.5.16
│ │ │ ├─┬ @storybook/api@6.5.16
│ │ │ │ └── regenerator-runtime@0.13.11 deduped
│ │ │ ├─┬ @storybook/components@6.5.16
│ │ │ │ └── regenerator-runtime@0.13.11 deduped
│ │ │ ├─┬ @storybook/theming@6.5.16
│ │ │ │ └── regenerator-runtime@0.13.11 deduped
│ │ │ └── regenerator-runtime@0.13.11
│ │ └── regenerator-runtime@0.13.11
│ └─┬ @storybook/preview-web@6.5.16
│   └── regenerator-runtime@0.13.11
├─┬ appium@1.22.3
│ ├─┬ appium-android-driver@4.54.0
│ │ └─┬ jimp@0.16.2
│ │   ├─┬ @jimp/custom@0.16.2
│ │   │ └─┬ @jimp/core@0.16.2
│ │   │   └─┬ @jimp/utils@0.16.2
│ │   │     └── regenerator-runtime@0.13.11
│ │   └── regenerator-runtime@0.13.11
│ └─┬ appium-tizen-driver@1.1.1-beta.5
│   └─┬ jimp@0.5.6
│     └─┬ @babel/polyfill@7.12.1
│       └── regenerator-runtime@0.13.11
├─┬ react-native@0.71.14 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
│ └── regenerator-runtime@0.13.11
└── regenerator-runtime@0.13.9

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)
  • or resolve @metamask/assets-controllers>babel-runtime
    • from v6.26.0 to v7.8.4+ (regenerator-runtime: ^0.13.2, which locks to 0.13.11)
  • ethjs patches still needed?

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

Related issues

Fixes: #8015

Screenshot 2023-12-07 at 4 03 00 pm

Fixes: #8017

Additional context

Manual testing steps

Steps in Sentry issue breadcrumbs (iOS prod)

To enable SES in debug-mode, omit !__DEV__

+if (Platform.OS === 'ios' && !global?.HermesInternal && !__DEV__) {
+ require('../../../../ses.cjs'); // ses@0.18.8

I've not managed to repro locally this way yet

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • 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.

Refactor gen func proto iterator symbol

obj prop assignment to Object.defineProperty
Copy link
Contributor

github-actions bot commented Dec 7, 2023

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@leotm leotm requested a review from Gudahtt December 7, 2023 16:34
@leotm leotm marked this pull request as ready for review December 7, 2023 16:34
@leotm leotm requested a review from a team as a code owner December 7, 2023 16:34
Copy link
Contributor

github-actions bot commented Dec 7, 2023

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/27e3bafe-0f8a-4644-8d6e-42bd5b1d8333
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

@leotm leotm marked this pull request as draft December 7, 2023 16:39
@leotm
Copy link
Member Author

leotm commented Dec 7, 2023

converted back to draft until failing/cancelled unit tests resolved

@leotm leotm mentioned this pull request Dec 7, 2023
13 tasks
@leotm leotm added the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Dec 8, 2023
@leotm leotm marked this pull request as ready for review December 8, 2023 13:17
Copy link
Contributor

github-actions bot commented Dec 8, 2023

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/fae1b7fb-caf2-4b2d-bffa-c491fe9b4f38
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

@leotm
Copy link
Member Author

leotm commented Dec 8, 2023

pr re-readied up, since CI flakey unit tests unrelated to this pr

issue appears fixed, based on Sentry logs, solution and our prev solution in mm-ext

@leotm
Copy link
Member Author

leotm commented Dec 8, 2023

once

is merged, we can update this branch, and unit tests should be passing again

and PR is ready for QA

we shouldn't need to disable SES

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7e66fb0) 40.33% compared to head (b689c5c) 40.33%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8033   +/-   ##
=======================================
  Coverage   40.33%   40.33%           
=======================================
  Files        1235     1235           
  Lines       29949    29949           
  Branches     2875     2875           
=======================================
  Hits        12079    12079           
  Misses      17175    17175           
  Partials      695      695           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Since was disabled as crash hotfix
- CI unit test failures were due to Node v18.19 not SES
- All regenerator-runtime vers now SES-compatible (v0.13.8+)
@leotm leotm changed the title fix: regenerator-runtime fix: regenerator-runtime and reenable SES on iOS (JSC) Dec 13, 2023
Copy link

sonarcloud bot commented Dec 13, 2023

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@leotm leotm removed the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Jan 17, 2024
Copy link
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a273882e-3ca2-4d7d-a332-9df00fe1e0c6
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

@leotm leotm changed the title fix: regenerator-runtime and reenable SES on iOS (JSC) fix: regenerator-runtime and reenable SES (v1.1.0) on iOS (JSC) Jan 18, 2024
@leotm
Copy link
Member Author

leotm commented Jan 18, 2024

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a273882e-3ca2-4d7d-a332-9df00fe1e0c6 You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

build_smoke_e2e_ios_android_stage ✅
run_smoke_e2e_ios_android_stage ❌
iOS Failed to find Detox executable at path: /Users/vagrant/git/node_modules/.bin/detox :suspect:
Android Failed to find Detox executable at path: /bitrise/src/node_modules/.bin/detox :suspect:

local testing

watchman shutdown-server && watchman watch-del-all && git clean -fdx && nvm use && export METAMASK_BUILD_TYPE="main" && export METAMASK_ENVIRONMENT="local" && yarn setup

nvm use && export METAMASK_BUILD_TYPE='main' && export METAMASK_ENVIRONMENT='local' && IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:bitrise:build

nvm use && export METAMASK_BUILD_TYPE='main' && export METAMASK_ENVIRONMENT='local' && IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:bitrise:run --testNamePattern="Smoke"

Screenshot 2024-01-19 at 12 22 48 pm

all smoke tests passing locally, update branch and re-run BitRise Smoke tests (Rebuild unsuccessful Workflows with remote access unsuccessful)

@leotm
Copy link
Member Author

leotm commented Jan 19, 2024

https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d36076eb-cdf7-4179-9d94-15ac845bc5a5

all regression tests also passing locally

Screenshot 2024-01-19 at 3 39 39 pm

@Cal-L
Copy link
Contributor

Cal-L commented Jan 19, 2024

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/a273882e-3ca2-4d7d-a332-9df00fe1e0c6 You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

build_smoke_e2e_ios_android_stage ✅ run_smoke_e2e_ios_android_stage ❌ iOS Failed to find Detox executable at path: /Users/vagrant/git/node_modules/.bin/detox :suspect: Android Failed to find Detox executable at path: /bitrise/src/node_modules/.bin/detox :suspect:

local testing

watchman shutdown-server && watchman watch-del-all && git clean -fdx && nvm use && export METAMASK_BUILD_TYPE="main" && export METAMASK_ENVIRONMENT="local" && yarn setup

nvm use && export METAMASK_BUILD_TYPE='main' && export METAMASK_ENVIRONMENT='local' && IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:bitrise:build

nvm use && export METAMASK_BUILD_TYPE='main' && export METAMASK_ENVIRONMENT='local' && IGNORE_BOXLOGS_DEVELOPMENT="true" FORCE_BUNDLING=true yarn test:e2e:ios:bitrise:run --testNamePattern="Smoke"

Screenshot 2024-01-19 at 12 22 48 pm all smoke tests passing locally, update branch and re-run BitRise Smoke tests (`Rebuild unsuccessful Workflows with remote access` unsuccessful)

I believe there were issues with our E2E tests on Bitrise. @cortisiko @chrisleewilcox could you confirm?

@Cal-L
Copy link
Contributor

Cal-L commented Jan 19, 2024

@leotm Are you aware if the latest core controllers already resolve this issue? If not, could you follow up with a PR to core that performs one of the following?

  • resolve @metamask/assets-controllers>babel-runtime>regenerator-runtime
    from v0.11.1 to v0.13.8+ (containing fix)
  • resolve @metamask/assets-controllers>babel-runtime
    from v6.26.0 to v7.8.4+ (regenerator-runtime: ^0.13.2, which locks to 0.13.11)

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

left a comment and some questions

ses.cjs Show resolved Hide resolved
@leotm
Copy link
Member Author

leotm commented Jan 22, 2024

@leotm Are you aware if the latest core controllers already resolve this issue? If not, could you follow up with a PR to core that performs one of the following?

  • resolve @metamask/assets-controllers>babel-runtime>regenerator-runtime
    from v0.11.1 to v0.13.8+ (containing fix)
  • resolve @metamask/assets-controllers>babel-runtime
    from v6.26.0 to v7.8.4+ (regenerator-runtime: ^0.13.2, which locks to 0.13.11)

good question after checking core(main) appears fixed now

@metamask/core-monorepo@109.0.0
└─┬ @metamask/transaction-controller@20.0.0 -> ./packages/transaction-controller
  └─┬ babel-runtime@6.26.0
    └── regenerator-runtime@0.11.1

since @metamask/assets-controllers no longer relies on regenerator-runtime
removed in @metamask/core-monorepo@67.0.0 (MetaMask/core#1504), which is@metamask/assets-controllers@11.0.0
so upgrading our @metamask/assets-controllers from v7 to v11-24 is SES-compatible, running local tests on those
(noting we also have patches/@metamask+assets-controllers+7.0.0.patch)

edit: tried bumping @metamask/assets-controllers from v7 to v11

Screenshot 2024-01-22 at 12 49 44 pm

@tommasini @Gudahtt what would be the best way to upgrade our patch? (looking thru the 2.4k lines)

edit: after brief call with @tommasini doing our controller upgrades, our resolution seems best solution for now cc @Cal-L


also our final @metamask/core-monorepo SES lockdown incompatibility now lurks in @metamask/transaction-controller
so following up there with the resolution, unless we can do similar refeactor to remove babel-runtime deps?

And remove stale babel-runtime/regenerator-runtime resolution
Copy link

socket-security bot commented Jan 22, 2024

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

View full report↗︎

@leotm leotm requested a review from Cal-L January 22, 2024 13:23
@Gudahtt
Copy link
Member

Gudahtt commented Jan 22, 2024

I don't think updating that package would help; babel-runtime is the dependency of dozens of other packages as well, including some core packages.

@leotm
Copy link
Member Author

leotm commented Jan 22, 2024

also our final SES lockdown incompatibility now lurks in @metamask/transaction-controller
so following up there with the resolution, unless we can do similar refeactor to remove babel-runtime deps?

I don't think updating that package would help; babel-runtime is the dependency of dozens of other packages as well, including some core packages.

yeah i see what you mean

@metamask/core-monorepo@109.0.0
└─┬ @metamask/transaction-controller@20.0.0 -> ./packages/transaction-controller
  ├── babel-runtime@6.26.0
  └─┬ eth-method-registry@3.0.0
    └─┬ @metamask/ethjs@0.5.1
      ├─┬ @metamask/ethjs-contract@0.3.4
      │ └── babel-runtime@6.26.0 deduped
      └─┬ @metamask/ethjs-query@0.5.3
        └── babel-runtime@6.26.0 deduped

ok leaving it for now, unless a resolution like MetaMask/core#3809 would make sense over there too

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

sonarcloud bot commented Jan 23, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@leotm leotm merged commit 6d26e45 into main Jan 23, 2024
27 of 28 checks passed
@leotm leotm deleted the fix/ses-regenerator-runtime branch January 23, 2024 13:06
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2024
@metamaskbot metamaskbot added the release-7.16.0 Issue or pull request that will be included in release 7.16.0 label Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.16.0 Issue or pull request that will be included in release 7.16.0 team-lavamoat team-mobile-platform
Projects
None yet
6 participants