mirror of
https://github.com/flutter/flutter.git
synced 2026-02-13 22:31:34 +08:00
Revert "Revert "Ensure VmService instance is disposed after failed direct connection attempt (#66123)" (#66164)" (#66377)
This reverts commit 3e6863ab2bc5cd33b41646ec957969860af7d518.
This commit is contained in:
parent
2102bb0364
commit
a3b3d53d62
@ -156,9 +156,10 @@ class FallbackDiscovery {
|
||||
// Attempt to connect to the VM service 5 times.
|
||||
int attempts = 0;
|
||||
Exception firstException;
|
||||
VmService vmService;
|
||||
while (attempts < 5) {
|
||||
try {
|
||||
final VmService vmService = await _vmServiceConnectUri(
|
||||
vmService = await _vmServiceConnectUri(
|
||||
assumedWsUri.toString(),
|
||||
);
|
||||
final VM vm = await vmService.getVM();
|
||||
@ -167,15 +168,17 @@ class FallbackDiscovery {
|
||||
isolateRefs.id,
|
||||
);
|
||||
final LibraryRef library = isolateResponse.rootLib;
|
||||
if (library != null && library.uri.startsWith('package:$packageName')) {
|
||||
if (library != null &&
|
||||
(library.uri.startsWith('package:$packageName') ||
|
||||
library.uri.startsWith(RegExp(r'file:\/\/\/.*\/' + packageName)))) {
|
||||
UsageEvent(
|
||||
_kEventName,
|
||||
'success',
|
||||
flutterUsage: _flutterUsage,
|
||||
).send();
|
||||
|
||||
// We absolutely must dispose this vmService instance, otherwise
|
||||
// DDS will fail to start.
|
||||
// This vmService instance must be disposed of, otherwise DDS will
|
||||
// fail to start.
|
||||
vmService.dispose();
|
||||
return Uri.parse('http://localhost:$hostPort');
|
||||
}
|
||||
@ -184,6 +187,10 @@ class FallbackDiscovery {
|
||||
// No action, we might have failed to connect.
|
||||
firstException ??= err;
|
||||
_logger.printTrace(err.toString());
|
||||
} finally {
|
||||
// This vmService instance must be disposed of, otherwise DDS will
|
||||
// fail to start.
|
||||
vmService?.dispose();
|
||||
}
|
||||
|
||||
// No exponential backoff is used here to keep the amount of time the
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user