forked from firka/flutter
Adds a new helpful tool exit message for SocketExceptions thrown during mdns discovery (#157638)
Addresses https://github.com/flutter/flutter/issues/150131, but doesn't fix it, as there seem to be cases where the steps included in the messages added in this PR don't work.
This commit is contained in:
@@ -15,6 +15,7 @@ import 'base/logger.dart';
|
||||
import 'build_info.dart';
|
||||
import 'convert.dart';
|
||||
import 'device.dart';
|
||||
import 'globals.dart' as globals;
|
||||
import 'reporting/reporting.dart';
|
||||
|
||||
/// A wrapper around [MDnsClient] to find a Dart VM Service instance.
|
||||
@@ -229,10 +230,28 @@ class MDnsVmServiceDiscovery {
|
||||
final Set<String> uniqueDomainNamesInResults = <String>{};
|
||||
|
||||
// Listen for mDNS connections until timeout.
|
||||
final Stream<PtrResourceRecord> ptrResourceStream = client.lookup<PtrResourceRecord>(
|
||||
ResourceRecordQuery.serverPointer(dartVmServiceName),
|
||||
timeout: timeout
|
||||
);
|
||||
final Stream<PtrResourceRecord> ptrResourceStream;
|
||||
|
||||
try {
|
||||
ptrResourceStream = client.lookup<PtrResourceRecord>(
|
||||
ResourceRecordQuery.serverPointer(dartVmServiceName),
|
||||
timeout: timeout,
|
||||
);
|
||||
} on SocketException catch (e, stacktrace) {
|
||||
_logger.printError(e.message);
|
||||
_logger.printTrace(stacktrace.toString());
|
||||
if (globals.platform.isMacOS) {
|
||||
throwToolExit(
|
||||
'You might be having a permissions issue with your IDE. '
|
||||
'Please try going to '
|
||||
'System Settings -> Privacy & Security -> Local Network -> '
|
||||
'[Find your IDE] -> Toggle ON, then restart your phone.'
|
||||
);
|
||||
} else {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
await for (final PtrResourceRecord ptr in ptrResourceStream) {
|
||||
uniqueDomainNames.add(ptr.domainName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user