Skip to content

Clear pages polling interval on device recreate - #58928

Closed
vzaidman wants to merge 1 commit into
mainfrom
export-D123883324
Closed

vzaidman wants to merge 1 commit into
mainfrom
export-D123883324

Conversation

@vzaidman

@vzaidman vzaidman commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary:
Device#dangerouslyRecreateDevice overwrote #pagesPollingIntervalId without clearing the previous interval. The old device socket's close handler could not clear it either, because its socket === #deviceSocket guard fails once reconstruct points #deviceSocket at the new socket. Every device ID collision therefore leaked a ref'd 1s getPages polling timer: the new device received duplicate polls, and the event loop was kept alive (Jest suites covering device handoff never exited on their own).

Clear the previous polling interval before reconstructing. Clearing an already-cleared interval is a no-op, so the path where the old socket already closed is unaffected.

With the leak fixed, test suites that exercise device handoff exit on their own, so their results can be relied on without force-exiting Jest.

Changelog:
[General][Fixed] - Fix the inspector proxy leaking a pages polling timer, and sending duplicate getPages requests, each time a device reconnects with the same device ID

Differential Revision: D123883324

Summary:
`Device#dangerouslyRecreateDevice` overwrote `#pagesPollingIntervalId` without clearing the previous interval. The old device socket's `close` handler could not clear it either, because its `socket === #deviceSocket` guard fails once reconstruct points `#deviceSocket` at the new socket. Every device ID collision therefore leaked a ref'd 1s `getPages` polling timer: the new device received duplicate polls, and the event loop was kept alive (Jest suites covering device handoff never exited on their own).

Clear the previous polling interval before reconstructing. Clearing an already-cleared interval is a no-op, so the path where the old socket already closed is unaffected.

With the leak fixed, test suites that exercise device handoff exit on their own, so their results can be relied on without force-exiting Jest.

Changelog:
[General][Fixed] - Fix the inspector proxy leaking a pages polling timer, and sending duplicate `getPages` requests, each time a device reconnects with the same device ID

Differential Revision: D123883324
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 7, 2026
@facebook-github-tools facebook-github-tools Bot added p: Facebook Partner: Facebook Partner labels Oct 7, 2026
@meta-codesync

meta-codesync Bot commented Oct 7, 2026

Copy link
Copy Markdown

@vzaidman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D123883324.

@vzaidman
vzaidman requested a review from motiz88 October 7, 2026 16:46
@meta-codesync meta-codesync Bot closed this in 268b302 Oct 7, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 7, 2026
@meta-codesync

meta-codesync Bot commented Oct 7, 2026

Copy link
Copy Markdown

This pull request has been merged in 268b302.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant