Skip to content

Commit 34a364c

Browse files
committed
fix: guard performance_stop_trace when tracing inactive
1 parent 7d5f28e commit 34a364c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/tools/performance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const stopTrace = defineTool({
111111
},
112112
schema: {},
113113
handler: async (_request, response, context) => {
114-
if (!context.isRunningPerformanceTrace) {
114+
if (!context.isRunningPerformanceTrace()) {
115115
return;
116116
}
117117
const page = context.getSelectedPage();

tests/tools/performance.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,11 @@ describe('performance', () => {
218218
it('does nothing if the trace is not running and does not error', async () => {
219219
await withBrowser(async (response, context) => {
220220
context.setIsRunningPerformanceTrace(false);
221+
const selectedPage = context.getSelectedPage();
222+
const stopTracingStub = sinon.stub(selectedPage.tracing, 'stop');
221223
await stopTrace.handler({params: {}}, response, context);
224+
sinon.assert.notCalled(stopTracingStub);
225+
assert.strictEqual(context.isRunningPerformanceTrace(), false);
222226
});
223227
});
224228

0 commit comments

Comments
 (0)