Skip to content

Commit fae5e53

Browse files
authored
Merge pull request #1779 from hey-api/fix/debug-missing-mark
fix: dont throw on missing performance marks
2 parents 64e46eb + 57fcec8 commit fae5e53

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

.changeset/chilled-tips-lie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: don't throw on missing performance marks

packages/openapi-ts/bin/index.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ async function start() {
117117
userConfig.watch = Number.parseInt(params.watch, 10);
118118
}
119119

120+
if (!Object.keys(userConfig.logs).length) {
121+
delete userConfig.logs;
122+
}
123+
120124
const context = await createClient(userConfig);
121125
if (!context[0] || !context[0].config.watch) {
122126
process.exit(0);

packages/openapi-ts/src/utils/performance.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ export class PerformanceReport {
3232
);
3333

3434
marks.forEach((mark) => {
35-
const markMeasure = Performance.measure(mark);
36-
const markDuration = Math.ceil(markMeasure.duration * 100) / 100;
37-
const percentage =
38-
Math.ceil(
39-
(markMeasure.duration / this.totalMeasure.duration) * 100 * 100,
40-
) / 100;
41-
console.warn(
42-
`${mark}: ${markDuration.toFixed(2)}ms (${percentage.toFixed(2)}%)`,
43-
);
35+
try {
36+
const markMeasure = Performance.measure(mark);
37+
const markDuration = Math.ceil(markMeasure.duration * 100) / 100;
38+
const percentage =
39+
Math.ceil(
40+
(markMeasure.duration / this.totalMeasure.duration) * 100 * 100,
41+
) / 100;
42+
console.warn(
43+
`${mark}: ${markDuration.toFixed(2)}ms (${percentage.toFixed(2)}%)`,
44+
);
45+
} catch {
46+
// noop
47+
}
4448
});
4549
}
4650
}

0 commit comments

Comments
 (0)