Skip to content

Commit 00ec296

Browse files
authored
Don't connect the SSE API when running embedded (#9020)
See #8298 See #8763
1 parent f10e8df commit 00ec296

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

packages/devtools_app/lib/src/shared/config_specific/framework_initialize/_framework_initialize_web.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ Future<String> initializePlatform() async {
2828
);
2929

3030
// TODO(kenz): this server connection initialized listeners that are never
31-
// disposed, so this is likely leaking resources.
31+
// disposed, so this is likely leaking resources.
3232
// Here, we try and initialize the connection between the DevTools web app and
3333
// its local server. DevTools can be launched without the server however, so
3434
// establishing this connection is a best-effort.
35-
// TODO(kenz): investigate it we can remove the DevToolsServerConnection
36-
// code in general. We do not appear to be using the SSE connection.
35+
// TODO(kenz): investigate if we can remove the DevToolsServerConnection
36+
// code in general - it is currently only used for non-embedded pages to
37+
// support some functionality like having VS Code reuse existing browser tabs
38+
// and showing notifications if you try to launch when you already have one
39+
// open.
3740
final connection = await DevToolsServerConnection.connect();
3841
if (connection != null) {
3942
setGlobal(Storage, server.ServerConnectionStorage());

packages/devtools_app/lib/src/shared/server/server_api_client.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:async';
66
import 'dart:convert';
77

8+
import 'package:devtools_app_shared/ui.dart' show isEmbedded;
89
import 'package:devtools_shared/devtools_shared.dart';
910
import 'package:flutter/foundation.dart';
1011
import 'package:http/http.dart' as http;
@@ -47,6 +48,14 @@ class DevToolsServerConnection {
4748
: baseUri.resolve('api/');
4849

4950
static Future<DevToolsServerConnection?> connect() async {
51+
// Don't connect SSE when running embedded because the API does not provide
52+
// anything that is used when embedded but it ties up one of the limited
53+
// number of connections to the server.
54+
// https://github.com/flutter/devtools/issues/8298
55+
if (isEmbedded()) {
56+
return null;
57+
}
58+
5059
final serverUri = Uri.parse(devToolsServerUriAsString);
5160
final apiUri = apiUriFor(serverUri);
5261
final pingUri = apiUri.resolve('ping');

0 commit comments

Comments
 (0)