Skip to content

Commit

Permalink
fix: dont throw on missing performance marks
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Mar 4, 2025
1 parent 9eccf4b commit 57fcec8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-tips-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

fix: don't throw on missing performance marks
4 changes: 4 additions & 0 deletions packages/openapi-ts/bin/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ async function start() {
userConfig.watch = Number.parseInt(params.watch, 10);
}

if (!Object.keys(userConfig.logs).length) {
delete userConfig.logs;
}

const context = await createClient(userConfig);
if (!context[0] || !context[0].config.watch) {
process.exit(0);
Expand Down
22 changes: 13 additions & 9 deletions packages/openapi-ts/src/utils/performance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ export class PerformanceReport {
);

marks.forEach((mark) => {
const markMeasure = Performance.measure(mark);
const markDuration = Math.ceil(markMeasure.duration * 100) / 100;
const percentage =
Math.ceil(
(markMeasure.duration / this.totalMeasure.duration) * 100 * 100,
) / 100;
console.warn(
`${mark}: ${markDuration.toFixed(2)}ms (${percentage.toFixed(2)}%)`,
);
try {
const markMeasure = Performance.measure(mark);
const markDuration = Math.ceil(markMeasure.duration * 100) / 100;
const percentage =
Math.ceil(
(markMeasure.duration / this.totalMeasure.duration) * 100 * 100,
) / 100;
console.warn(
`${mark}: ${markDuration.toFixed(2)}ms (${percentage.toFixed(2)}%)`,
);
} catch {
// noop
}

Check warning on line 47 in packages/openapi-ts/src/utils/performance.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/utils/performance.ts#L35-L47

Added lines #L35 - L47 were not covered by tests
});
}
}

0 comments on commit 57fcec8

Please sign in to comment.