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

[core][updates] fix error recovery on android #28177

Merged
merged 3 commits into from
Apr 13, 2024

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Apr 12, 2024

Why

the error recovery of updates was broken since https://github.com/expo/expo/pull/27629/files#diff-b034a3a37c87b036bb0d9c0549d6701774c79fedb4892dd44807d8947d75d4fbL27-R37. apparently when ReactContext is available, it's too late for error recovery because bundle is loaded and may throw exceptions already.

How

  • i feel [core][updates] Add bridgeless support for ReactNativeHostHandler #27629's change is correct for onDidCreateReactInstance. for error recovery we sound like need to call point between onWillCreateReactInstance and DevSupportManager available (error recovery requires DevSupportManager to detect exceptions). this pr introduces a new onDidCreateDevSupportManager for this purpose.
  • also fix incorrect onWillCreateReactInstance timing on bridgeless mode
  • seen a detox failed from proguard that i have to add an additional proguard rule to fix that.

Test Plan

test based on #28050
i need further change to the detox e2e

  • detox does not support reload well, it will encounter the detox error and enter infinite waiting loop. the reason is that the detox access to the old ReactContext which is not the same with the new ReactContext reloading from error recovery. i have to patch the [expo-update][e2e] Add error recovery e2e test #28050 test
    diff --git a/packages/expo-updates/e2e/fixtures/Updates-error-recovery.e2e.ts b/packages/expo-updates/e2e/fixtures/Updates-error-recovery.e2e.ts
    index 016a204516..92b429c506 100644
    --- a/packages/expo-updates/e2e/fixtures/Updates-error-recovery.e2e.ts
    +++ b/packages/expo-updates/e2e/fixtures/Updates-error-recovery.e2e.ts
    @@ -19,6 +19,23 @@ const waitForAppToBecomeVisible = async () => {
         .withTimeout(2000);
     };
    
    +function launchAppWithTimeout(timeout: number) {
    +  return new Promise(async (resolve, reject) => {
    +    setTimeout(() => {
    +      reject(new Error('Launch timed out'));
    +    }, timeout);
    +
    +    try {
    +      await device.launchApp({
    +        newInstance: true,
    +      });
    +      resolve(null);  // If successful, resolve the promise.
    +    } catch (error) {
    +      reject(error);  // If the launchApp itself fails, reject the promise.
    +    }
    +  });
    +}
    +
     describe('Error recovery tests', () => {
       afterEach(async () => {
         await device.uninstallApp();
    @@ -69,9 +86,7 @@ describe('Error recovery tests', () => {
         // we don't check current update ID header or failed update IDs header since the behavior for this request is not defined
         // (we don't guarantee current update to be set during a crash or the launch failure to have been registered yet)
         await jestExpect(
    -      device.launchApp({
    -        newInstance: true,
    -      })
    +      launchAppWithTimeout(2000)
         ).rejects.toThrow();
         const request2 = await Server.waitForUpdateRequest(10000);
         const request2EmbeddedUpdateId = request2.headers['expo-embedded-update-id'];

Checklist

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 12, 2024
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Apr 12, 2024
@expo-bot
Copy link
Collaborator

expo-bot commented Apr 12, 2024

The Pull Request introduced fingerprint changes against the base commit: 8b52a69

Fingerprint diff
[
  {
    "type": "dir",
    "filePath": "../../packages/expo-modules-core/android",
    "reasons": [
      "expoAutolinkingAndroid"
    ],
    "hash": "5c63d7d66259fecbedd3b302ede82ac88406c117"
  },
  {
    "type": "dir",
    "filePath": "../../packages/expo-updates/android",
    "reasons": [
      "expoAutolinkingAndroid"
    ],
    "hash": "1ee15c237dad83e46e687aa95c575dcb8c3d7f24"
  },
  {
    "type": "dir",
    "filePath": "../../packages/expo/android",
    "reasons": [
      "expoAutolinkingAndroid"
    ],
    "hash": "0bde56915036ba0e2595e085e24a1f4b3c6d9a80"
  }
]

Generated by PR labeler 🤖

@Kudo
Copy link
Contributor Author

Kudo commented Apr 12, 2024

android instrumentation test was failed from #28163 (comment)

@Kudo Kudo marked this pull request as ready for review April 12, 2024 17:49
@Kudo Kudo removed request for brentvatne and ide April 12, 2024 17:49
@Kudo Kudo merged commit b33e8c3 into main Apr 13, 2024
17 of 18 checks passed
@Kudo Kudo deleted the @kudo/fix-update-error-recovery branch April 13, 2024 05:16
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint changed bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants