Skip to content

fix(debug-controller): drop recorded actions when recording session ends - #42458

Merged
Dmitry Gozman (dgozman) merged 2 commits into
microsoft:mainfrom
ashrafiucse:fix-42218
Sep 2, 2026
Merged

fix(debug-controller): drop recorded actions when recording session ends#42458
Dmitry Gozman (dgozman) merged 2 commits into
microsoft:mainfrom
ashrafiucse:fix-42218

Conversation

@ashrafiucse

@ashrafiucse Ashraf Ali (ashrafiucse) commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • clear the accumulated recorder actions when the recorder mode switches to none, so the next recording session on the same page starts from a clean list
  • the list was never cleared before, so a late signal (dialog, navigation, popup) re-rendered a stale previous-session action as the last one, and clients diffing by count - e.g. the VS Code extension's "Record at cursor" - inserted that stale action into the editor

Addresses the cross-session variant of #42218. The mid-recording variant is fixed on the extension side: microsoft/playwright-vscode#807

Related: #42461 keeps the browser open after stopping a debug session, extending the record-after-debug workflow (#37822).

The debug controller accumulates recorder actions in a closure and
re-sends the full list in every `sourceChanged` event. The list was
never cleared when recording was disabled, so a subsequent recording
session on the same page leaked the previous session's actions: a late
signal (dialog, navigation, popup) re-rendered a stale action as the
last one, and clients that diff by count - like the VS Code extension's
"Record at cursor" - inserted that stale action into the editor.

Clear the accumulated actions when the recorder mode switches to
'none', so each session starts from a clean list.

Fixes: microsoft#42218
// Recording session has ended: drop the accumulated actions, so that the
// next session does not leak them into the emitted source (the client
// would re-insert the stale last action into the editor).
if (mode === 'none')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this include 'standby' as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, added — standby is what the toolbar's record toggle switches to when you pause, so it clears the list now as well.

One wrinkle: the protocol only accepts inspecting/recording/none, so the test drives the actual record button in the toolbar instead of calling setRecorderMode directly.

The firefox failure turned out to be my test's fault, not the fix — setContent is recorded as a goto('about:blank') there, so the second session was legitimately emitting one extra action. Switched that part to swapping innerHTML directly and it's green on both engines now.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…refox test

Address review feedback: 'standby' (recorder toolbar pause) is a session
end as well, so it clears the accumulated actions too. The firefox failure
was a test expectation issue: setContent is recorded as a goto on firefox,
so session 2 now avoids navigation; the standby path is covered through
the real toolbar toggle since 'standby' is not settable via the protocol.
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

7 flaky ⚠️ [chromium-library] › library/video.spec.ts:699 › screencast › should capture full viewport on hidpi `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:699 › screencast › should capture full viewport on hidpi `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`
⚠️ [playwright-test] › ui-mode-trace.spec.ts:827 › should update state on subsequent run `@windows-latest-node22`

51283 passed, 1241 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

1 failed
❌ [firefox] › mcp/cli-drag.spec.ts:19 › drag between elements @mcp-windows-latest-firefox

8304 passed, 1367 skipped


Merge workflow run.

@dgozman

Copy link
Copy Markdown
Collaborator

Looks good, thank you for the PR.

@dgozman
Dmitry Gozman (dgozman) merged commit b34b234 into microsoft:main Sep 2, 2026
44 of 45 checks passed
Ashraf Ali (ashrafiucse) added a commit to ashrafiucse/playwright-vscode that referenced this pull request Sep 2, 2026
Add a regression test for the cross-session variant of the issue, fixed
core-side in microsoft/playwright#42458. The test
is skipped until the bundled @playwright/test includes that fix (1.63.0+).

Also wait for the recorded action insert to fully settle (text present and
selection spanning it) before simulating the user edit, so the mid-recording
test does not race the extension's editor updates.

Fixes: microsoft/playwright#42218
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants