Skip to content

Send an event notifying DWDS when the debugger is detached #1595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Remove clearing all scripts on page load for extension debugger.
- Fix breakpoints not hitting after changing a base in index.html.
- Find best locations for call frames, breakpoints, or expression evaluation.
- Close the SSE connection when a DebugExtension.detached event is received.

**Breaking changes:**
- Add `basePath` parameter to `FrontendServerRequireStrategy`.
Expand Down
1 change: 1 addition & 0 deletions dwds/debug_extension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Notify the debugger and inspector panels when the debug session is disconnected.
- Provide a detailed error message when the debugger fails to connect.
- Send an event to the server when the debugger is detached.

## 1.28

Expand Down
8 changes: 8 additions & 0 deletions dwds/debug_extension/web/background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ int _removeDebugSessionForTab(int tabId) {
(session) => session.appTabId == tabId || session.devtoolsTabId == tabId,
orElse: () => null);
if (session != null) {
// Note: package:sse will try to keep the connection alive, even after the
// client has been closed. Therefore the extension sends an event to notify
// DWDS that we should close the connection, instead of relying on the done
// event sent when the client is closed. See details:
// https://github.com/dart-lang/webdev/pull/1595#issuecomment-1116773378
final event =
_extensionEventFor('DebugExtension.detached', js_util.jsify({}));
session.socketClient.sink.add(jsonEncode(serializers.serialize(event)));
session.socketClient.close();
_debugSessions.remove(session);

Expand Down
Loading