Skip to content

Fix error message on dds failure2 #1865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
or not.
- Pre-warm expression compiler cache to speed up Flutter Inspector loading.
- Remove `ChromeProxyService.setExceptionPauseMode()`.
- Display full error on failure to start DDS.

## 16.0.1

Expand Down
5 changes: 1 addition & 4 deletions dwds/debug_extension_mv3/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ dev_dependencies:
built_value_generator: ^8.3.0
build_web_compilers: ^3.0.0
dwds: ^16.0.0
sse: ^4.1.0
sse: ^4.1.2
web_socket_channel: ^2.2.0

dependency_overrides:
dwds:
path: ..
# TODO(elliette): Remove override once package:sse is published.
sse:
path: /Users/elliottbrooks/dev/sse
2 changes: 1 addition & 1 deletion dwds/lib/src/dwds_vm_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class DwdsVmClient {
'error': {
'code': kFeatureDisabled,
'message': kFeatureDisabledMessage,
'details':
'data':
'Existing VM service clients prevent DDS from taking control.',
},
};
Expand Down
1 change: 1 addition & 0 deletions dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ class ChromeProxyService implements VmServiceInterface {
void destroyIsolate() {
_logger.fine('Destroying isolate');
if (!_isIsolateRunning) return;

final isolate = inspector.isolate;
final isolateRef = inspector.isolateRef;

Expand Down
38 changes: 38 additions & 0 deletions dwds/test/debug_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,42 @@ void main() {
.then((ws) => ws.close()),
completes);
});

test('Refuses to yield to dwds if existing clients found', () async {
final ddsWs = await WebSocket.connect(
'${context.debugConnection.uri}/ws',
);

// Connect to vm service.
final ws = await WebSocket.connect('${context.debugConnection.uri}/ws');

final completer = Completer<Map<String, dynamic>>();
ddsWs.listen((event) {
completer.complete(json.decode(event as String));
});

const yieldControlToDDS = <String, dynamic>{
'jsonrpc': '2.0',
'id': '0',
'method': '_yieldControlToDDS',
'params': {
'uri': 'http://localhost:123',
},
};

// DDS should fail to start with existing vm clients.
ddsWs.add(json.encode(yieldControlToDDS));

final response = await completer.future;
expect(response['id'], '0');
expect(response.containsKey('error'), isTrue);

final result = response['error'] as Map<String, dynamic>;
expect(result['message'], 'Feature is disabled.');
expect(result['data'],
'Existing VM service clients prevent DDS from taking control.');

await ddsWs.close();
await ws.close();
});
}