Skip to content

Commit c24bc27

Browse files
authored
[Property Editor] Use new DTD api to check if the connection is closed (#9066)
1 parent 29aa8bd commit c24bc27

3 files changed

Lines changed: 5 additions & 24 deletions

File tree

packages/devtools_app/lib/src/shared/editor/editor_client.dart

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class EditorClient extends DisposableController
3030

3131
String get gaId => EditorSidebar.id;
3232

33+
bool get isDtdClosed => _dtd.isClosed;
34+
3335
Future<void> _initialize() async {
3436
autoDisposeStreamSubscription(
3537
_dtd.onEvent('Service').listen((data) {
@@ -317,27 +319,6 @@ class EditorClient extends DisposableController
317319
}
318320
}
319321

320-
Future<bool> isClientClosed() async {
321-
try {
322-
// Make an empty request to DTD.
323-
await _dtd.call('', '');
324-
} on StateError catch (e) {
325-
// TODO(https://github.com/flutter/devtools/issues/9028): Replace with a
326-
// check for whether DTD is closed. Requires a change to package:dtd.
327-
//
328-
// This is only a temporary fix. If the error in package:json_rpc_2 is
329-
// changed, this will no longer catch it. See:
330-
// https://github.com/dart-lang/tools/blob/b55643dadafd3ac6b2bd20823802f75929ebf98e/pkgs/json_rpc_2/lib/src/client.dart#L151
331-
if (e.message.contains('The client is closed.')) {
332-
return true;
333-
}
334-
} catch (e) {
335-
// Ignore other exceptions. If the client is open, we expect this to fail
336-
// with the error: 'Unknown method "."'.
337-
}
338-
return false;
339-
}
340-
341322
Future<DTDResponse> _call(
342323
EditorMethod method, {
343324
Map<String, Object?>? params,

packages/devtools_app/lib/src/standalone_ui/ide_shared/property_editor/property_editor_controller.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ class PropertyEditorController extends DisposableController
181181
}
182182

183183
Timer _periodicallyCheckConnection(Duration interval) {
184-
return Timer.periodic(interval, (timer) async {
185-
final isClosed = await editorClient.isClientClosed();
184+
return Timer.periodic(interval, (timer) {
185+
final isClosed = editorClient.isDtdClosed;
186186
if (isClosed) {
187187
_shouldReconnect.value = true;
188188
timer.cancel();

packages/devtools_app/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies:
2525
devtools_app_shared:
2626
devtools_extensions:
2727
devtools_shared:
28-
dtd: ^2.4.0
28+
dtd: ^2.5.0
2929
file: ^7.0.0
3030
file_selector: ^1.0.0
3131
fixnum: ^1.1.0

0 commit comments

Comments
 (0)