Skip to content

Commit a0b9bae

Browse files
authored
Send an event notifying DWDS when the debugger is detached (#1595)
1 parent 88da408 commit a0b9bae

File tree

5 files changed

+4848
-4819
lines changed

5 files changed

+4848
-4819
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Remove clearing all scripts on page load for extension debugger.
1111
- Fix breakpoints not hitting after changing a base in index.html.
1212
- Find best locations for call frames, breakpoints, or expression evaluation.
13+
- Close the SSE connection when a DebugExtension.detached event is received.
1314

1415
**Breaking changes:**
1516
- Add `basePath` parameter to `FrontendServerRequireStrategy`.

dwds/debug_extension/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

67
## 1.28
78

dwds/debug_extension/web/background.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ int _removeDebugSessionForTab(int tabId) {
295295
(session) => session.appTabId == tabId || session.devtoolsTabId == tabId,
296296
orElse: () => null);
297297
if (session != null) {
298+
// Note: package:sse will try to keep the connection alive, even after the
299+
// client has been closed. Therefore the extension sends an event to notify
300+
// DWDS that we should close the connection, instead of relying on the done
301+
// event sent when the client is closed. See details:
302+
// https://github.com/dart-lang/webdev/pull/1595#issuecomment-1116773378
303+
final event =
304+
_extensionEventFor('DebugExtension.detached', js_util.jsify({}));
305+
session.socketClient.sink.add(jsonEncode(serializers.serialize(event)));
298306
session.socketClient.close();
299307
_debugSessions.remove(session);
300308

0 commit comments

Comments
 (0)