Skip to content

fix: Fix native matchVersion not allowing patch version mismatches#9018

Merged
tjzel merged 1 commit into
software-mansion:mainfrom
kitten:@kitten/fix/native-version-majmin-comparator
Feb 26, 2026
Merged

fix: Fix native matchVersion not allowing patch version mismatches#9018
tjzel merged 1 commit into
software-mansion:mainfrom
kitten:@kitten/fix/native-version-majmin-comparator

Conversation

@kitten

@kitten kitten commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Summary

While this looked correct and we looked at this for the SDK 54 release in September, we again found warnings when the patch versions mismatch, and assume that when we reviewed this, we missed something.

Coming back to this and looking closer, the old code compared std::smatch directly against each other from both searches. However, std::smatch is an iterator, and, presumably, the comparison is iterating all values and comparing them. The string at the zero-index, like in JS, is a full match string. If that match string contains the full version string, then the comparison can never succeed.

This means that this was always comparing exact version matches rather than allowing patch versions to differ.

Instead, the new version matches two explicit groups on major and minor versions for clarity, then compares index 1 and 2's (match 1 and 2's ) strings.

Test plan

  • Test of previously failing behaviour
    • Compile a native app with newer/older versions (e.g. react-native-reanimated@4.2.2 and react-native-worklets@0.7.2
    • Then; use a bundle against different versions (e.g. react-native-reanimated@4.2.1 and react-native-worklets@0.7.4
    • Before: C++ mismatch warning logs in console, although major & minor are compatible
    • After: No warning is logged
  • Test to validate that the warning can still log after the change
    • Manually change JS versions in package.json to bump minor
    • Update hardcoded jsVersion to bump minor
    • Clear and rebundle JS, observing the warning in the console and a worklets error (not from Babel but in the runtime)

@kitten
kitten force-pushed the @kitten/fix/native-version-majmin-comparator branch from c43d73b to d834760 Compare February 26, 2026 14:17
While this looked correct and we looked at this for the SDK 54 release
in September, we again found warnings when the patch versions mismatch,
and assume that when we reviewed this, we missed something.

Coming back to this and looking closer, the old code compared
`std::smatch` directly against each other from both searches. However,
`std::smatch` is an iterator, and, presumably, the comparison is
iterating all values and comparing them. The string at the zero-index,
like in JS, is a full match string. If that match string contains the
full `version` string, then the comparison can never succeed.

This means that this was always comparing exact version matches rather
than allowing patch versions to differ.

Instead, the new version matches two explicit groups on major and minor
versions for clarity, then compares index 1 and 2's (match 1 and 2's )
strings.
@kitten
kitten force-pushed the @kitten/fix/native-version-majmin-comparator branch from d834760 to 3fbfefb Compare February 26, 2026 14:17

@tjzel tjzel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I tested and all works well!

@kitten

kitten commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

I updated the test plan. I also checked the check still fails when the minor version mismatches, as expected, to make sure the check isn't a noop 👍

@tjzel
tjzel added this pull request to the merge queue Feb 26, 2026
Merged via the queue into software-mansion:main with commit abb8469 Feb 26, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants