Skip to content

add websocketDisconnectedPageRemoved - #285

Open
vzaidman wants to merge 1 commit into
mainfrom
add-disconnected-page-removed-text
Open

vzaidman wants to merge 1 commit into
mainfrom
add-disconnected-page-removed-text

Conversation

@vzaidman

@vzaidman vzaidman commented Oct 7, 2026 •

Copy link
Copy Markdown

Summary

When a React Native instance is destroyed while DevTools is attached, the inspector proxy closes the debugger connection with the [PAGE_REMOVED] close reason (D123882926). Map it to a user-facing message in the disconnected dialog instead of the generic "WebSocket disconnected".

Test plan

See D123882926

Built the frontend, ran Metro with REACT_NATIVE_DEBUGGER_FRONTEND_PATH pointing at the local build and the dev-middleware/native changes from D123882926, destroyed the React Native instance while DevTools was attached, and verified the dialog shows "The React Native instance being debugged no longer exists. Relaunch DevTools to debug a new instance."

  • This change maintains backwards compatibility with previous Local Storage data (if modifying settings, experiments, or other persisted client state).

Upstreaming plan

@meta-cla meta-cla Bot added the cla signed label Oct 7, 2026
@vzaidman
vzaidman requested a review from motiz88 October 7, 2026 16:14
meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Oct 7, 2026
Summary:

Notice: react/react-native-devtools-frontend#285 needs to land to display the human readable error properly in the disconnection dialog, but this fix works regardless.

When a React Native host is destroyed while DevTools is attached (e.g. the app recreates its React Native instance), the DevTools frontend stayed open in a broken state: the console stopped receiving output, breakpoints were not respected, and no "disconnected" dialog was shown. Two issues combined:

1. `InspectorPackagerConnection` disconnected the local sessions when a page was removed, but the resulting `disconnect` notification was dropped because the session had already been erased, so the dev server was never told that the session ended.
2. The inspector proxy ignored device `disconnect` events for pages with the `nativePageReloads` capability, including connection rejections (e.g. when a debugger session is handed off to a reconnected device that no longer has the page), so the debugger WebSocket stayed open.

This change:
- Sends a `disconnect` event to the dev server for every session when a page is removed.
- Closes the debugger connection in the inspector proxy with a new `[PAGE_REMOVED]` close reason when the device ends or rejects a session on a `nativePageReloads` page, so the frontend shows its disconnected dialog.
- Adds a `DisconnectEventFromDevice` type with an optional `sessionId`, matching the documented protocol for legacy devices.
- Adds a test ensuring all close reasons fit within the 123-byte WebSocket close frame limit.

Changelog:
[General][Fixed] - Fix React Native DevTools staying open but unresponsive after the debugged React Native instance is destroyed

Differential Revision: D123882926
meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Oct 7, 2026
Summary:

Notice: react/react-native-devtools-frontend#285 needs to land to display the human readable error properly in the disconnection dialog, but this fix works regardless.

When a React Native host is destroyed while DevTools is attached (e.g. the app recreates its React Native instance), the DevTools frontend stayed open in a broken state: the console stopped receiving output, breakpoints were not respected, and no "disconnected" dialog was shown. Two issues combined:

1. `InspectorPackagerConnection` disconnected the local sessions when a page was removed, but the resulting `disconnect` notification was dropped because the session had already been erased, so the dev server was never told that the session ended.
2. The inspector proxy ignored device `disconnect` events for pages with the `nativePageReloads` capability, including connection rejections (e.g. when a debugger session is handed off to a reconnected device that no longer has the page), so the debugger WebSocket stayed open.

This change:
- Sends a `disconnect` event to the dev server for every session when a page is removed.
- Closes the debugger connection in the inspector proxy with a new `[PAGE_REMOVED]` close reason when the device ends or rejects a session on a `nativePageReloads` page, so the frontend shows its disconnected dialog.
- Adds a `DisconnectEventFromDevice` type with an optional `sessionId`, matching the documented protocol for legacy devices.
- Adds a test ensuring all close reasons fit within the 123-byte WebSocket close frame limit.

Changelog:
[General][Fixed] - Fix React Native DevTools staying open but unresponsive after the debugged React Native instance is destroyed

Differential Revision: D123882926
meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Oct 7, 2026
Summary:
Pull Request resolved: #58927

Notice: react/react-native-devtools-frontend#285 needs to land to display the human readable error properly in the disconnection dialog, but this fix works regardless.

When a React Native host is destroyed while DevTools is attached (e.g. the app recreates its React Native instance), the DevTools frontend stayed open in a broken state: the console stopped receiving output, breakpoints were not respected, and no "disconnected" dialog was shown. Two issues combined:

1. `InspectorPackagerConnection` disconnected the local sessions when a page was removed, but the resulting `disconnect` notification was dropped because the session had already been erased, so the dev server was never told that the session ended.
2. The inspector proxy ignored device `disconnect` events for pages with the `nativePageReloads` capability, including connection rejections (e.g. when a debugger session is handed off to a reconnected device that no longer has the page), so the debugger WebSocket stayed open.

This change:
- Sends a `disconnect` event to the dev server for every session when a page is removed.
- Closes the debugger connection in the inspector proxy with a new `[PAGE_REMOVED]` close reason when the device ends or rejects a session on a `nativePageReloads` page, so the frontend shows its disconnected dialog.
- Adds a `DisconnectEventFromDevice` type with an optional `sessionId`, matching the documented protocol for legacy devices.
- Adds a test ensuring all close reasons fit within the 123-byte WebSocket close frame limit.

Changelog:
[General][Fixed] - Fix React Native DevTools staying open but unresponsive after the debugged React Native instance is destroyed

Differential Revision: D123882926
meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Oct 8, 2026
Summary:

Notice: react/react-native-devtools-frontend#285 needs to land to display the human readable error properly in the disconnection dialog, but this fix works regardless.

When a React Native host is destroyed while DevTools is attached (e.g. the app recreates its React Native instance), the DevTools frontend stayed open in a broken state: the console stopped receiving output, breakpoints were not respected, and no "disconnected" dialog was shown. Two issues combined:

1. `InspectorPackagerConnection` disconnected the local sessions when a page was removed, but the resulting `disconnect` notification was dropped because the session had already been erased, so the dev server was never told that the session ended.
2. The inspector proxy ignored device `disconnect` events for pages with the `nativePageReloads` capability, including connection rejections (e.g. when a debugger session is handed off to a reconnected device that no longer has the page), so the debugger WebSocket stayed open.

This change:
- Sends a `disconnect` event to the dev server for every session when a page is removed.
- Closes the debugger connection in the inspector proxy with a new `[PAGE_REMOVED]` close reason when the device ends or rejects a session on a `nativePageReloads` page, so the frontend shows its disconnected dialog.
- Adds a `DisconnectEventFromDevice` type with an optional `sessionId`, matching the documented protocol for legacy devices.
- Adds a test ensuring all close reasons fit within the 123-byte WebSocket close frame limit.

Changelog:
[General][Fixed] - Fix React Native DevTools staying open but unresponsive after the debugged React Native instance is destroyed

Differential Revision: D123882926
meta-codesync Bot pushed a commit to react/react-native that referenced this pull request Oct 8, 2026
Summary:
Pull Request resolved: #58927

Notice: react/react-native-devtools-frontend#285 needs to land to display the human readable error properly in the disconnection dialog, but this fix works regardless.

When a React Native host is destroyed while DevTools is attached (e.g. the app recreates its React Native instance), the DevTools frontend stayed open in a broken state: the console stopped receiving output, breakpoints were not respected, and no "disconnected" dialog was shown. Two issues combined:

1. `InspectorPackagerConnection` disconnected the local sessions when a page was removed, but the resulting `disconnect` notification was dropped because the session had already been erased, so the dev server was never told that the session ended.
2. The inspector proxy ignored device `disconnect` events for pages with the `nativePageReloads` capability, including connection rejections (e.g. when a debugger session is handed off to a reconnected device that no longer has the page), so the debugger WebSocket stayed open.

This change:
- Sends a `disconnect` event to the dev server for every session when a page is removed.
- Closes the debugger connection in the inspector proxy with a new `[PAGE_REMOVED]` close reason when the device ends or rejects a session on a `nativePageReloads` page, so the frontend shows its disconnected dialog.
- Adds a `DisconnectEventFromDevice` type with an optional `sessionId`, matching the documented protocol for legacy devices.
- Adds a test ensuring all close reasons fit within the 123-byte WebSocket close frame limit.

Changelog:
[General][Fixed] - Fix React Native DevTools staying open but unresponsive after the debugged React Native instance is destroyed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant