From 4bdfaf222ba4a222a3f01e595b26e36799e33a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 13 Apr 2026 04:31:04 -0700 Subject: [PATCH] Fix stateful regex bug in benchmark detection (#56423) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56423 Changelog: [Internal] The `FANTOM_BENCHMARK_FILENAME_RE` and `FANTOM_BENCHMARK_SUITE_RE` regexes used the `g` (global) flag, which makes `.test()` stateful — it preserves `lastIndex` between calls. When `getFantomTestConfigs` is called for multiple test files in the same process, the stale `lastIndex` from a previous successful match causes `.test()` to miss the match on the next file, returning `false`. This results in benchmark files intermittently getting the default dev config (`isJsOptimized: false`, `dev: true`), causing them to fail at runtime with "Benchmarks should not be run in development mode". Removes the `g` flag from both regexes since they are used with `.test()` across different strings and should be stateless. ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: react_native_iroc Differential Revision: D100603612 fbshipit-source-id: 4eded9b0a59a2343ad44c0c1c2855466e3981b7a --- private/react-native-fantom/runner/getFantomTestConfigs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/private/react-native-fantom/runner/getFantomTestConfigs.js b/private/react-native-fantom/runner/getFantomTestConfigs.js index 918802f5dc9..d86d7c91617 100644 --- a/private/react-native-fantom/runner/getFantomTestConfigs.js +++ b/private/react-native-fantom/runner/getFantomTestConfigs.js @@ -72,9 +72,9 @@ export const DEFAULT_FEATURE_FLAGS: FantomTestConfigFeatureFlags = { const FANTOM_FLAG_FORMAT = /^(\w+):((?:\w+)|\*)$/; -const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./g; +const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./; const FANTOM_BENCHMARK_SUITE_RE = - /\n(Fantom\.)?unstable_benchmark(\s*)\.suite\(/g; + /\n(Fantom\.)?unstable_benchmark(\s*)\.suite\(/; const MAX_FANTOM_CONFIGURATION_VARIATIONS = 12;