From a03574c6b37bfaa5a8ad6a36c98b729d40cfbb4b Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Sat, 5 Sep 2026 16:02:03 +0300 Subject: [PATCH] test: Allow the async stress test to finish under sanitizers --- apps/example/rn-harness.config.mjs | 3 ++- apps/example/src/getTests.ts | 3 ++- apps/example/src/testing/createTestRunner.ts | 15 +++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/example/rn-harness.config.mjs b/apps/example/rn-harness.config.mjs index 6e3015306f..c867b2c399 100644 --- a/apps/example/rn-harness.config.mjs +++ b/apps/example/rn-harness.config.mjs @@ -33,7 +33,8 @@ const config = { ], defaultRunner: 'android', resetEnvironmentBetweenTestFiles: 'runtime', - testTimeout: process.env.CI === 'true' ? 30000 : 10000, + // The async HybridObject stress test has its own 120-second deadline. + testTimeout: process.env.CI === 'true' ? 150000 : 10000, platformReadyTimeout: process.env.CI === 'true' ? 420000 : 300000, bridgeTimeout: process.env.CI === 'true' ? 180000 : 60000, bundleStartTimeout: process.env.CI === 'true' ? 120000 : 60000, diff --git a/apps/example/src/getTests.ts b/apps/example/src/getTests.ts index 0c698e436a..51a5e3d0ae 100644 --- a/apps/example/src/getTests.ts +++ b/apps/example/src/getTests.ts @@ -48,6 +48,7 @@ export interface TestRunner { // 2) In JVM, 51_200 is the limit for `jni::global_ref`s, then the app crashes - this intentionally exhausts that const MEMORY_LEAK_TEST_ALLOCATION_COUNT = 55_000 const EXTERNAL_MEMORY_TEST_SIZE = 1024 * 1024 +const PARALLEL_HYBRID_OBJECT_TEST_TIMEOUT = 120_000 type HermesInternal = { getInstrumentedStats?: () => { js_externalBytes: number } @@ -1549,7 +1550,7 @@ export function getTests( ) } return true - }) + }, PARALLEL_HYBRID_OBJECT_TEST_TIMEOUT) ) .didNotThrow() .equals(true) diff --git a/apps/example/src/testing/createTestRunner.ts b/apps/example/src/testing/createTestRunner.ts index ba1c645c69..271bf81039 100644 --- a/apps/example/src/testing/createTestRunner.ts +++ b/apps/example/src/testing/createTestRunner.ts @@ -32,21 +32,24 @@ function timeoutedPromise( } export interface TestRunner { - it(action: () => Promise): Promise> - it(action: () => T): State + it(action: () => Promise, timeout?: number): Promise> + it(action: () => T, timeout?: number): State } /** * Creates a test runner with the provided assertion backend. */ export function createTestRunner(backend: AssertionBackend): TestRunner { - function it(action: () => Promise): Promise> - function it(action: () => T): State - function it(action: () => T | Promise): State | Promise> { + function it(action: () => Promise, timeout?: number): Promise> + function it(action: () => T, timeout?: number): State + function it( + action: () => T | Promise, + timeout?: number + ): State | Promise> { try { const syncResult = action() if (syncResult instanceof Promise) { - const wrapped = timeoutedPromise(syncResult) + const wrapped = timeoutedPromise(syncResult, timeout) return wrapped .then((asyncResult) => new State(asyncResult, undefined, backend)) .catch((error) => new State(undefined, error, backend))