Skip to content

AI-native design editor. Open-source Figma alternative.

fix(ci): preserve phase outcomes when timing reports fail

Danila Poyarkov750f5dcde76f
diff --git a/tools/package-quality/src/timing.ts b/tools/package-quality/src/timing.ts
index b482ac541..3164c96e5 100644
--- a/tools/package-quality/src/timing.ts
+++ b/tools/package-quality/src/timing.ts
@@ -10,8 +10,11 @@ export async function measurePhase<T>(
outcome = 'completed'
return result
} finally {
- report(
- `[package-quality] ${name}: ${outcome} in ${((performance.now() - started) / 1000).toFixed(2)}s`
- )
+ try {
+ report(
+ `[package-quality] ${name}: ${outcome} in ${((performance.now() - started) / 1000).toFixed(2)}s`
+ )
+ // oxlint-disable-next-line open-pencil/no-silent-catch -- Reporting must not change the phase outcome.
+ } catch {}
}
}
diff --git a/tools/package-quality/tests/runtime.test.ts b/tools/package-quality/tests/runtime.test.ts
index ff98abee3..27474c646 100644
--- a/tools/package-quality/tests/runtime.test.ts
+++ b/tools/package-quality/tests/runtime.test.ts
@@ -54,6 +54,34 @@ test('public imports retain separate bounded Node and Bun invocations and the st
}
})
+test('phase timing preserves successful results when reporting throws', async () => {
+ const result = { verified: true }
+ expect(
+ await measurePhase(
+ 'imports',
+ async () => result,
+ () => {
+ throw new Error('report failed')
+ }
+ )
+ ).toBe(result)
+})
+
+test('phase timing preserves the original exception when reporting throws', async () => {
+ const error = new Error('failed import')
+ await expect(
+ measurePhase(
+ 'imports',
+ async () => {
+ throw error
+ },
+ () => {
+ throw new Error('report failed')
+ }
+ )
+ ).rejects.toBe(error)
+})
+
test('phase timing preserves results and exceptions', async () => {
const reports: string[] = []
const result = { verified: true }