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

Unify error messages and add Troubleshooting section to docs #4915

Merged
merged 20 commits into from
Aug 22, 2023

Conversation

tjzel
Copy link
Contributor

@tjzel tjzel commented Aug 10, 2023

Summary

Since version checker PR #4914 will add more error messages to Reanimated and our Troubleshooting section in docs was almost non-existent I decided to add a new one.

To make it consistent I made all errors thrown by Reanimated start with [Reanimated] and prettified them a bit.

With this I made this tiny script validate-urls.js that scans our source code to get valid (not so exotic) URLs and checks if they are available.

Test plan

CI

@tjzel tjzel mentioned this pull request Aug 10, 2023
@tjzel tjzel marked this pull request as ready for review August 17, 2023 17:11
docs/docs/guides/troubleshooting.mdx Outdated Show resolved Hide resolved
docs/docs/guides/troubleshooting.mdx Outdated Show resolved Hide resolved
docs/docs/guides/troubleshooting.mdx Outdated Show resolved Hide resolved
src/reanimated2/Bezier.ts Outdated Show resolved Hide resolved
src/reanimated2/globals.d.ts Outdated Show resolved Hide resolved
src/reanimated2/interpolation.ts Outdated Show resolved Hide resolved
src/reanimated2/interpolation.ts Outdated Show resolved Hide resolved
@tjzel tjzel requested a review from tomekzaw August 21, 2023 15:01
Common/cpp/SharedItems/Shareables.h Outdated Show resolved Hide resolved
Common/cpp/Tools/SingleInstanceChecker.h Outdated Show resolved Hide resolved
android/build.gradle Show resolved Hide resolved
android/build.gradle Outdated Show resolved Hide resolved
android/src/main/cpp/NativeProxy.cpp Outdated Show resolved Hide resolved
scripts/reanimated_utils.rb Outdated Show resolved Hide resolved
scripts/reanimated_utils.rb Outdated Show resolved Hide resolved
scripts/reanimated_utils.rb Outdated Show resolved Hide resolved
src/reanimated2/interpolation.ts Outdated Show resolved Hide resolved
src/reanimated2/interpolation.ts Outdated Show resolved Hide resolved
Copy link
Member

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

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

CI is red 😢

Copy link
Member

@tomekzaw tomekzaw left a comment

Choose a reason for hiding this comment

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

CI is green 😄

@tjzel tjzel added this pull request to the merge queue Aug 22, 2023
Merged via the queue into main with commit 8ef27c2 Aug 22, 2023
21 checks passed
@tjzel tjzel deleted the @tjzel/troubleshooting branch August 22, 2023 18:12
piaskowyk pushed a commit that referenced this pull request Sep 27, 2023
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

This PR is a pinnacle of Reanimated's version detection grand scheme.

Since there are numerous errors stemming from having parts of Reanimated
used from different version we decided to enforce runtime checks for
those parts - to make the troubleshooting process easier.

Adding:
- C++ checks JavaScript version
- C++ checks Java version
- Java checks C++ version


Requires #4915  

## Test plan

1. C++ checks JavaScript version:

Trigger failed resolution:

```diff
// src/reanimated2/NativeReanimated/NativeReanimated.ts
-  global._REANIMATED_VERSION_JS = jsVersion;
```

Trigger wrong version:

```diff
// src/reanimated2/NativeReanimated/NativeReanimated.ts
- global._REANIMATED_VERSION_JS = jsVersion;
+ global._REANIMATED_VERSION_JS = 'wrong-version';
```

2. C++ checks Java version:

Trigger failed resolution:

```diff
// android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java
  public String getReanimatedJavaVersion() {
-   return BuildConfig.REANIMATED_VERSION_JAVA;
+   throw new RuntimeException("forced fail");
  }
```

Trigger wrong version:

```diff
// android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java
  public String getReanimatedJavaVersion() {
-   return BuildConfig.REANIMATED_VERSION_JAVA;
+   return new String("wrong-version");
  }
```

3. Java checks C++ version:

Trigger failed resolution:

```diff
// android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java
  protected void setCppVersion(String version) {
-   cppVersion = version;
+   // NOOP
  }
```

Trigger wrong version:

```diff
// android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java
  protected void setCppVersion(String version) {
-   cppVersion = version;
+   cppVersion = new String("wrong-version");
  }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants