Skip to content

fix(screencast): guard frame callback and cleanup listeners#661

Closed
Kikobeats wants to merge 1 commit intomasterfrom
codex/fix-screencast-listener-cleanup
Closed

fix(screencast): guard frame callback and cleanup listeners#661
Kikobeats wants to merge 1 commit intomasterfrom
codex/fix-screencast-listener-cleanup

Conversation

@Kikobeats
Copy link
Member

@Kikobeats Kikobeats commented Feb 26, 2026

Note

Low Risk
Low risk: small, localized lifecycle fixes to event handling with added unit coverage; main risk is behavior change around when frames are delivered/ignored and how stop is handled across CDP implementations.

Overview
Hardens the screencast frame handler by guarding onFrame so early Page.screencastFrame events don’t throw, while still acking frames.

Makes stop() idempotent and removes the Page.screencastFrame listener on stop (supporting both cdp.off and removeListener) to prevent leaks/double-processing, and adds AVA unit tests covering both behaviors.

Written by Cursor Bugbot for commit 74ecf1d. This will update automatically on new commits. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

if (typeof cdp.off === 'function') {
cdp.off('Page.screencastFrame', onScreencastFrame)
} else if (typeof cdp.removeListener === 'function') {
cdp.removeListener('Page.screencastFrame', onScreencastFrame)
Copy link

Choose a reason for hiding this comment

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

Screencast cannot restart after first stop

Medium Severity

stop() now permanently removes the Page.screencastFrame listener and flips isStopped, but start() never reattaches that listener or resets state. Reusing the same instance after one stop causes frames to stop being processed and acknowledged, and later stop() calls become no-ops for subsequent recording sessions.

Fix in Cursor Fix in Web

@Kikobeats Kikobeats closed this Feb 26, 2026
@Kikobeats Kikobeats deleted the codex/fix-screencast-listener-cleanup branch February 26, 2026 16:50
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.

1 participant