From 587c0e6126c38ec78618c10396733f19f58b1a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 13 Apr 2026 03:37:12 -0700 Subject: [PATCH] Fix stateful regex bug in benchmark detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: 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. Differential Revision: D100603612 --- 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 918802f5dc91..d86d7c91617c 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;