Skip to content

Commit 4067462

Browse files
authored
Fix reading pause_isolates_on_start value from the DWDS (#2398)
1 parent ee8c967 commit 4067462

File tree

4 files changed

+16
-29
lines changed

4 files changed

+16
-29
lines changed

dwds/lib/dart_web_debug_service.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class Dwds {
4747
StreamController<DebugConnection> get extensionDebugConnections =>
4848
_devHandler.extensionDebugConnections;
4949

50-
bool get shouldPauseIsolatesOnStart => _shouldPauseIsolatesOnStart;
51-
bool _shouldPauseIsolatesOnStart = false;
52-
5350
Future<void> stop() async {
5451
await _devTools?.close();
5552
await _devHandler.close();
@@ -61,9 +58,6 @@ class Dwds {
6158
final appDebugServices = await _devHandler.loadAppServices(appConnection);
6259
final chromeProxyService = appDebugServices.chromeProxyService;
6360
await chromeProxyService.isInitialized;
64-
chromeProxyService.pauseIsolatesOnStartStream.listen((value) {
65-
_shouldPauseIsolatesOnStart = value;
66-
});
6761
return DebugConnection(appDebugServices);
6862
}
6963

@@ -145,4 +139,7 @@ class Dwds {
145139
debugSettings.enableDebugging,
146140
);
147141
}
142+
143+
bool shouldPauseIsolatesOnStart(String appId) =>
144+
_devHandler.shouldPauseIsolatesOnStart(appId);
148145
}

dwds/lib/src/handlers/dev_handler.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ class DevHandler {
121121
_servicesByAppId.clear();
122122
}();
123123

124+
bool shouldPauseIsolatesOnStart(String appId) =>
125+
_servicesByAppId[appId]?.chromeProxyService.pauseIsolatesOnStart ?? false;
126+
124127
void _emitBuildResults(BuildResult result) {
125128
if (result.status != BuildStatus.succeeded) return;
126129
for (var injectedConnection in _injectedConnections) {

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,6 @@ class ChromeProxyService implements VmServiceInterface {
9898
/// This value can be updated at runtime via [setFlag].
9999
bool get pauseIsolatesOnStart => _pauseIsolatesOnStart;
100100

101-
final _pauseIsolatesOnStartController = StreamController<bool>.broadcast();
102-
103-
/// A global stream of the value of the [_pauseIsolatesOnStartFlag].
104-
///
105-
/// The flag's value can be updated during runtime.
106-
Stream<bool> get pauseIsolatesOnStartStream =>
107-
_pauseIsolatesOnStartController.stream;
108-
109101
final _resumeAfterHotRestartEventsController =
110102
StreamController<String>.broadcast();
111103

@@ -1227,7 +1219,6 @@ ${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.
12271219
if (name == _pauseIsolatesOnStartFlag) {
12281220
assert(value == 'true' || value == 'false');
12291221
_pauseIsolatesOnStart = value == 'true';
1230-
_pauseIsolatesOnStartController.sink.add(_pauseIsolatesOnStart);
12311222
}
12321223

12331224
return Success();

dwds/test/chrome_proxy_service_test.dart

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,34 +2064,30 @@ void main() {
20642064
});
20652065

20662066
group('setFlag', () {
2067-
test('pause_isolates_on_start set to true', () async {
2067+
test('pause_isolates_on_start set to true', () {
20682068
final service = context.service;
20692069
expect(
20702070
service.setFlag('pause_isolates_on_start', 'true'),
20712071
completion(_isSuccess),
20722072
);
2073-
// Re-try until sucess because the value doesn't get updated
2074-
// synchronously (it is sent over a stream):
2075-
final pauseIsolatesOnStart = await retryFn(
2076-
() => context.dwds!.shouldPauseIsolatesOnStart,
2077-
expectedResult: true,
2073+
final appId = context.appConnection.request.appId;
2074+
expect(
2075+
context.dwds!.shouldPauseIsolatesOnStart(appId),
2076+
equals(true),
20782077
);
2079-
expect(pauseIsolatesOnStart, equals(true));
20802078
});
20812079

2082-
test('pause_isolates_on_start set to false', () async {
2080+
test('pause_isolates_on_start set to false', () {
20832081
final service = context.service;
20842082
expect(
20852083
service.setFlag('pause_isolates_on_start', 'false'),
20862084
completion(_isSuccess),
20872085
);
2088-
// Re-try until sucess because the value doesn't get updated
2089-
// synchronously (it is sent over a stream):
2090-
final pauseIsolatesOnStart = await retryFn(
2091-
() => context.dwds!.shouldPauseIsolatesOnStart,
2092-
expectedResult: false,
2086+
final appId = context.appConnection.request.appId;
2087+
expect(
2088+
context.dwds!.shouldPauseIsolatesOnStart(appId),
2089+
equals(false),
20932090
);
2094-
expect(pauseIsolatesOnStart, equals(false));
20952091
});
20962092

20972093
test('pause_isolates_on_start set to invalid value', () {

0 commit comments

Comments
 (0)