Skip to content

Commit 733af11

Browse files
authored
[ DWDS ] Correctly report the current pause state for the WebSocketProxyService (#2710)
Fixes failing tests that started when attempting to roll 26.2.1 into Flutter. Also prepares for 26.2.2 release.
1 parent be9f117 commit 733af11

File tree

6 files changed

+16
-27
lines changed

6 files changed

+16
-27
lines changed

dwds/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 26.2.2
2+
3+
- Fix issue where isolate pause events were not reported correctly when using the web socket proxy service.
4+
15
## 26.2.1
26

37
- Add support for DDS APIs and serving Dart DevTools when no Chrome Debugger is available.

dwds/lib/src/connections/app_connection.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class AppConnection {
2020
final SocketConnection _connection;
2121
final Future<void> _readyToRunMain;
2222

23+
bool get hasStarted => _startedCompleter.isCompleted;
24+
2325
AppConnection(this.request, this._connection, this._readyToRunMain) {
2426
safeUnawaited(_connection.sink.done.then((v) => _doneCompleter.complete()));
2527
}

dwds/lib/src/injected/client.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/lib/src/services/web_socket/web_socket_proxy_service.dart

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,6 @@ final class WebSocketProxyService extends ProxyService<WebSocketAppInspector> {
192192
return service;
193193
}
194194

195-
// Isolate state
196-
vm_service.Event? _currentPauseEvent;
197-
bool _mainHasStarted = false;
198-
199195
/// Creates a new isolate for WebSocket debugging.
200196
@override
201197
Future<void> createIsolate(
@@ -276,7 +272,7 @@ final class WebSocketProxyService extends ProxyService<WebSocketAppInspector> {
276272
timestamp: timestamp,
277273
isolate: isolateRef,
278274
);
279-
_currentPauseEvent = pauseEvent;
275+
inspector.isolate.pauseEvent = pauseEvent;
280276
streamNotify(vm_service.EventStreams.kDebug, pauseEvent);
281277
}
282278

@@ -383,8 +379,6 @@ final class WebSocketProxyService extends ProxyService<WebSocketAppInspector> {
383379

384380
// Reset state
385381
inspector = null;
386-
_currentPauseEvent = null;
387-
_mainHasStarted = false;
388382

389383
if (initializedCompleter.isCompleted) {
390384
initializedCompleter = Completer<void>();
@@ -784,13 +778,13 @@ final class WebSocketProxyService extends ProxyService<WebSocketAppInspector> {
784778
value == 'true' &&
785779
oldValue == false) {
786780
// Send pause event for existing isolate if not already paused
787-
if (isIsolateRunning && _currentPauseEvent == null) {
781+
if (isIsolateRunning && inspector.isolate.pauseEvent == null) {
788782
final pauseEvent = vm_service.Event(
789783
kind: vm_service.EventKind.kPauseStart,
790784
timestamp: DateTime.now().millisecondsSinceEpoch,
791785
isolate: inspector.isolateRef,
792786
);
793-
_currentPauseEvent = pauseEvent;
787+
inspector.isolate.pauseEvent = pauseEvent;
794788
streamNotify(vm_service.EventStreams.kDebug, pauseEvent);
795789
}
796790
}
@@ -812,24 +806,13 @@ final class WebSocketProxyService extends ProxyService<WebSocketAppInspector> {
812806
Future<Success> _resume(String isolateId) async {
813807
if (hasPendingRestart && !resumeAfterRestartEventsController.isClosed) {
814808
resumeAfterRestartEventsController.add(isolateId);
815-
} else {
816-
if (!_mainHasStarted) {
817-
try {
818-
appConnection.runMain();
819-
_mainHasStarted = true;
820-
} catch (e) {
821-
if (e.toString().contains('Main has already started')) {
822-
_mainHasStarted = true;
823-
} else {
824-
rethrow;
825-
}
826-
}
827-
}
809+
} else if (!appConnection.hasStarted) {
810+
appConnection.runMain();
828811
}
829812

830813
// Clear pause state and send resume event to notify debugging tools
831-
if (_currentPauseEvent != null) {
832-
_currentPauseEvent = null;
814+
if (inspector.isolate.pauseEvent != null) {
815+
inspector.isolate.pauseEvent = null;
833816
final resumeEvent = vm_service.Event(
834817
kind: vm_service.EventKind.kResume,
835818
timestamp: DateTime.now().millisecondsSinceEpoch,

dwds/lib/src/version.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dwds/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: dwds
22
# Every time this changes you need to run `dart run build_runner build`.
3-
version: 26.2.1
3+
version: 26.2.2
44

55
description: >-
66
A service that proxies between the Chrome debug protocol and the Dart VM

0 commit comments

Comments
 (0)