fix(mcp): check tracing state before stopping in browser_stop_tracing#41040
fix(mcp): check tracing state before stopping in browser_stop_tracing#41040SebTardif wants to merge 2 commits into
Conversation
browser_stop_tracing called tracing.stop() unconditionally before checking the traceLegendSymbol. If tracing was started via config (saveTrace: true) rather than via browser_start_tracing, the tool killed the config-initiated trace, then threw 'Tracing is not started'. The destructive side effect happened before the guard. Move the traceLegendSymbol check before tracing.stop() so the guard is evaluated first and the active trace is preserved on the error path. Bug introduced in microsoft#39646 (2026-03-12). Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
This comment has been minimized.
This comment has been minimized.
yury-s
left a comment
There was a problem hiding this comment.
Please fix infra / docs & lint (pull_request) and we can merge this.
The Config type does not have a saveTrace property, causing a TS2353 compile error in the docs & lint CI check. Simplify the test to verify the core behavior: calling browser_stop_tracing without browser_start_tracing returns an error. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
Fixed the TS2353 lint error in 82076da. Note: this is more than a lint fix. The third test originally verified two behaviors:
The |
|
Test results for "MCP"7243 passed, 1103 skipped Merge workflow run. |
browser_stop_tracingcallsbrowserContext.tracing.stop()unconditionally before checking thetraceLegendSymbolguard. When tracing was started via config (saveTrace: true) rather than via thebrowser_start_tracingtool, the symbol is not set. The tool kills the config-initiated trace recording, then throws "Tracing is not started." The destructive side effect fires before the guard check.Fix
Move the
traceLegendSymbolcheck beforetracing.stop()so the guard is evaluated first and the active trace is preserved on the error path.Trigger scenario
saveTrace = truein configcontext.ts:329-335(notraceLegendSymbolset)browser_stop_tracingtracing.stop()kills the config trace, then the symbol check throws "Tracing is not started"The config-initiated trace has its own cleanup via the disposable registered at
context.ts:336-340, so the tool should not interfere with it.Test
Added a test that starts with
saveTrace: true, callsbrowser_stop_tracing(expects error), then verifies the config trace is still active by confirmingbrowser_start_tracingfails with "Tracing has been already started."Bug introduced in #39646 (2026-03-12).