Fix health metrics race condition and improve expected-failure handling (#2387)

* Fix health monitoring

* fix compile error
This commit is contained in:
sunghyunkang1111
2026-02-17 12:54:04 -06:00
committed by GitHub
parent 39ac7cf3f2
commit cc26e2800e
3 changed files with 52 additions and 5 deletions

View File

@@ -7,14 +7,18 @@ import { ApplicationMetricPhase, CommonMetricPhase } from "./ScenarioConfig";
* Hook to automatically complete the Interactive phase when the component becomes interactive.
* Uses requestAnimationFrame to complete after the browser has painted.
*/
export function useInteractive(scenario: MetricScenario) {
export function useInteractive(scenario: MetricScenario, enabled = true) {
const { completePhase } = useMetricScenario();
React.useEffect(() => {
requestAnimationFrame(() => {
if (!enabled) {
return undefined;
}
const id = requestAnimationFrame(() => {
completePhase(scenario, CommonMetricPhase.Interactive);
});
}, [scenario, completePhase]);
return () => cancelAnimationFrame(id);
}, [scenario, completePhase, enabled]);
}
/**