Skip to content

Commit 191db5b

Browse files
bkonyisrujzs
andauthored
[ DWDS ] Prepare for 25.1.0+1 (#2696)
* [DWDS] Don't send PauseInterrupted event during a hot reload (#2695) Fixes dart-lang/sdk#61560 We rely on a pause within a hot reload to pause execution so that we can reregister breakpoints. However, the existing pause mechanism always sends a PauseInterrupted event, which then triggers the client to think this is a normal pause event and not an internal detail. Instead, we should have the ChromeProxyService signal to the debugger that this is an "internal pause" and therefore it should not send a regular pause event and should use a completer to signal the pause is done. Tests are refactored and updated to correctly check for the events when reregistering breakpoints. Specifically, it checks no other events besides the expected ones are sent. * [ DWDS ] Expose `dtdUri` via `DebugConnection` (#2694) This is needed to access the DTD instance spawned by DDS. --------- Co-authored-by: Srujan Gaddam <[email protected]>
1 parent 769a056 commit 191db5b

File tree

12 files changed

+492
-379
lines changed

12 files changed

+492
-379
lines changed

dwds/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 25.1.0+1
2+
3+
- Bump SDK constraint to ^3.10.0
4+
- Added 'scriptUri' parameter to compileExpressionToJs
5+
- Fix an issue in `reloadSources` where a `PauseInterrupted` event was sent. - [#61560](https://github.com/dart-lang/sdk/issues/61560)
6+
- Expose `dtdUri` via `DebugConnection`.
7+
18
## 25.1.0
29

310
- Added `DartDevelopmentServiceConfiguration` to allow for configuring DDS behavior.

dwds/lib/src/connections/debug_connection.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class DebugConnection {
4141
/// The endpoint of the Dart DevTools instance.
4242
String? get devToolsUri => _appDebugServices.devToolsUri?.toString();
4343

44+
/// The endpoint of the Dart Tooling Daemon (DTD).
45+
String? get dtdUri => _appDebugServices.dtdUri?.toString();
46+
4447
/// A client of the Dart VM Service with DWDS specific extensions.
4548
VmService get vmService => _appDebugServices.dwdsVmClient.client;
4649

dwds/lib/src/debugging/debugger.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,28 @@ class Debugger extends Domain {
9797
bool _isStepping = false;
9898
DartLocation? _previousSteppingLocation;
9999

100+
// If not null and not completed, the pause handler completes this instead of
101+
// sending a `PauseInterrupted` event to the event stream.
102+
//
103+
// In some cases e.g. a hot reload, DWDS pauses the execution itself in order
104+
// to handle debugging logic like breakpoints. In such cases, sending the
105+
// event to the event stream may trigger the client to believe that the user
106+
// sent the event. To avoid that and still signal that a pause is completed,
107+
// this completer is used. See https://github.com/dart-lang/sdk/issues/61560
108+
// for more details.
109+
Completer<void>? _internalPauseCompleter;
110+
100111
void updateInspector(AppInspectorInterface appInspector) {
101112
inspector = appInspector;
102113
_breakpoints.inspector = appInspector;
103114
}
104115

105-
Future<Success> pause() async {
116+
Future<Success> pause({bool internalPause = false}) async {
106117
_isStepping = false;
118+
if (internalPause) _internalPauseCompleter = Completer<void>();
107119
final result = await _remoteDebugger.pause();
108120
handleErrorIfPresent(result);
121+
await _internalPauseCompleter?.future;
109122
return Success();
110123
}
111124

@@ -635,7 +648,14 @@ class Debugger extends Domain {
635648
// DevTools is showing an overlay. Both cannot be shown at the same time.
636649
// _showPausedOverlay();
637650
isolate.pauseEvent = event;
638-
_streamNotify('Debug', event);
651+
final internalPauseCompleter = _internalPauseCompleter;
652+
if (event.kind == EventKind.kPauseInterrupted &&
653+
internalPauseCompleter != null &&
654+
!internalPauseCompleter.isCompleted) {
655+
internalPauseCompleter.complete();
656+
} else {
657+
_streamNotify('Debug', event);
658+
}
639659
}
640660

641661
/// Handles resume events coming from the Chrome connection.

dwds/lib/src/handlers/dev_handler.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ class DevHandler {
869869
dwdsStats,
870870
dds?.wsUri,
871871
dds?.devToolsUri,
872+
dds?.dtdUri,
872873
);
873874
final encodedUri = await debugService.encodedUri;
874875
_logger.info('Debug service listening on $encodedUri\n');

0 commit comments

Comments
 (0)