Skip to content

Commit 4bdfaf2

Browse files
rubennortemeta-codesync[bot]
authored andcommitted
Fix stateful regex bug in benchmark detection (#56423)
Summary: Pull Request resolved: #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
1 parent a8b39a2 commit 4bdfaf2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

private/react-native-fantom/runner/getFantomTestConfigs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ export const DEFAULT_FEATURE_FLAGS: FantomTestConfigFeatureFlags = {
7272

7373
const FANTOM_FLAG_FORMAT = /^(\w+):((?:\w+)|\*)$/;
7474

75-
const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./g;
75+
const FANTOM_BENCHMARK_FILENAME_RE = /[Bb]enchmark-itest\./;
7676
const FANTOM_BENCHMARK_SUITE_RE =
77-
/\n(Fantom\.)?unstable_benchmark(\s*)\.suite\(/g;
77+
/\n(Fantom\.)?unstable_benchmark(\s*)\.suite\(/;
7878

7979
const MAX_FANTOM_CONFIGURATION_VARIATIONS = 12;
8080

0 commit comments

Comments
 (0)