Skip to content

Commit

Permalink
Fix reading pause_isolates_on_start value from the DWDS (#2398)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette authored Mar 27, 2024
1 parent ee8c967 commit 4067462
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
9 changes: 3 additions & 6 deletions dwds/lib/dart_web_debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class Dwds {
StreamController<DebugConnection> get extensionDebugConnections =>
_devHandler.extensionDebugConnections;

bool get shouldPauseIsolatesOnStart => _shouldPauseIsolatesOnStart;
bool _shouldPauseIsolatesOnStart = false;

Future<void> stop() async {
await _devTools?.close();
await _devHandler.close();
Expand All @@ -61,9 +58,6 @@ class Dwds {
final appDebugServices = await _devHandler.loadAppServices(appConnection);
final chromeProxyService = appDebugServices.chromeProxyService;
await chromeProxyService.isInitialized;
chromeProxyService.pauseIsolatesOnStartStream.listen((value) {
_shouldPauseIsolatesOnStart = value;
});
return DebugConnection(appDebugServices);
}

Expand Down Expand Up @@ -145,4 +139,7 @@ class Dwds {
debugSettings.enableDebugging,
);
}

bool shouldPauseIsolatesOnStart(String appId) =>
_devHandler.shouldPauseIsolatesOnStart(appId);
}
3 changes: 3 additions & 0 deletions dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ class DevHandler {
_servicesByAppId.clear();
}();

bool shouldPauseIsolatesOnStart(String appId) =>
_servicesByAppId[appId]?.chromeProxyService.pauseIsolatesOnStart ?? false;

void _emitBuildResults(BuildResult result) {
if (result.status != BuildStatus.succeeded) return;
for (var injectedConnection in _injectedConnections) {
Expand Down
9 changes: 0 additions & 9 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ class ChromeProxyService implements VmServiceInterface {
/// This value can be updated at runtime via [setFlag].
bool get pauseIsolatesOnStart => _pauseIsolatesOnStart;

final _pauseIsolatesOnStartController = StreamController<bool>.broadcast();

/// A global stream of the value of the [_pauseIsolatesOnStartFlag].
///
/// The flag's value can be updated during runtime.
Stream<bool> get pauseIsolatesOnStartStream =>
_pauseIsolatesOnStartController.stream;

final _resumeAfterHotRestartEventsController =
StreamController<String>.broadcast();

Expand Down Expand Up @@ -1227,7 +1219,6 @@ ${globalToolConfiguration.loadStrategy.loadModuleSnippet}("dart_sdk").developer.
if (name == _pauseIsolatesOnStartFlag) {
assert(value == 'true' || value == 'false');
_pauseIsolatesOnStart = value == 'true';
_pauseIsolatesOnStartController.sink.add(_pauseIsolatesOnStart);
}

return Success();
Expand Down
24 changes: 10 additions & 14 deletions dwds/test/chrome_proxy_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2064,34 +2064,30 @@ void main() {
});

group('setFlag', () {
test('pause_isolates_on_start set to true', () async {
test('pause_isolates_on_start set to true', () {
final service = context.service;
expect(
service.setFlag('pause_isolates_on_start', 'true'),
completion(_isSuccess),
);
// Re-try until sucess because the value doesn't get updated
// synchronously (it is sent over a stream):
final pauseIsolatesOnStart = await retryFn(
() => context.dwds!.shouldPauseIsolatesOnStart,
expectedResult: true,
final appId = context.appConnection.request.appId;
expect(
context.dwds!.shouldPauseIsolatesOnStart(appId),
equals(true),
);
expect(pauseIsolatesOnStart, equals(true));
});

test('pause_isolates_on_start set to false', () async {
test('pause_isolates_on_start set to false', () {
final service = context.service;
expect(
service.setFlag('pause_isolates_on_start', 'false'),
completion(_isSuccess),
);
// Re-try until sucess because the value doesn't get updated
// synchronously (it is sent over a stream):
final pauseIsolatesOnStart = await retryFn(
() => context.dwds!.shouldPauseIsolatesOnStart,
expectedResult: false,
final appId = context.appConnection.request.appId;
expect(
context.dwds!.shouldPauseIsolatesOnStart(appId),
equals(false),
);
expect(pauseIsolatesOnStart, equals(false));
});

test('pause_isolates_on_start set to invalid value', () {
Expand Down

0 comments on commit 4067462

Please sign in to comment.