Chrome DevTools for coding agents
fix(performance): report an error when performance_stop_trace is called with no active trace (#3001) (#3126)
Yuri (IURII) Trukhine1703847faf9
diff --git a/src/tools/performance.ts b/src/tools/performance.tsindex beafff92..164ce60f 100644--- a/src/tools/performance.ts+++ b/src/tools/performance.ts@@ -158,6 +158,9 @@ export const stopTrace = definePageTool(() => ({},handler: async (request, response, context) => {if (!context.isRunningPerformanceTrace()) {+ response.appendResponseLine(+ 'Error: no active performance trace recording to stop.',+ );return;}const page = request.page;diff --git a/tests/tools/performance.test.ts b/tests/tools/performance.test.tsindex 792ad5d4..8471daf6 100644--- a/tests/tools/performance.test.ts+++ b/tests/tools/performance.test.ts@@ -392,7 +392,7 @@ describe('performance', () => {});describe('performance_stop_trace', () => {- it('does nothing if the trace is not running and does not error', async () => {+ it('returns an error message if no trace is running', async () => {const {page, context, response, args} = createHandlerMocks();context.isRunningPerformanceTrace.returns(false);@@ -400,7 +400,10 @@ describe('performance', () => {sinon.assert.notCalled(context.setIsRunningPerformanceTrace);sinon.assert.notCalled(context.storeTraceRecording);- sinon.assert.notCalled(response.appendResponseLine);+ sinon.assert.calledOnceWithExactly(+ response.appendResponseLine,+ 'Error: no active performance trace recording to stop.',+ );});it('will stop the trace and return trace info when a trace is running', async () => {