diff --git a/packages/custom_lint/CHANGELOG.md b/packages/custom_lint/CHANGELOG.md index f0a687f6..769cc9cb 100644 --- a/packages/custom_lint/CHANGELOG.md +++ b/packages/custom_lint/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased patch + +Optimized logic for finding an unused VM_service port. + ## 0.5.5 - 2023-10-26 - Support `hotreloader` 4.0.0 diff --git a/packages/custom_lint/lib/src/v2/server_to_client_channel.dart b/packages/custom_lint/lib/src/v2/server_to_client_channel.dart index 00685cdd..e287c225 100644 --- a/packages/custom_lint/lib/src/v2/server_to_client_channel.dart +++ b/packages/custom_lint/lib/src/v2/server_to_client_channel.dart @@ -13,15 +13,6 @@ import '../workspace.dart'; import 'custom_lint_analyzer_plugin.dart'; import 'protocol.dart'; -Future _findPossiblyUnusedPort() { - return SocketCustomLintServerToClientChannel._createServerSocket() - .then((value) { - final port = value.port; - value.close(); - return port; - }); -} - Future _asyncRetry( Future Function() cb, { required int retryCount, @@ -170,12 +161,10 @@ class SocketCustomLintServerToClientChannel { _writeEntrypoint(_workspace.uniquePluginNames, tempDir); return _asyncRetry(retryCount: 5, () async { - // Using "late" to fetch the port only if needed (in watch mode) - late final port = _findPossiblyUnusedPort(); final process = await Process.start( Platform.resolvedExecutable, [ - if (_server.watchMode) '--enable-vm-service=${await port}', + if (_server.watchMode) '--enable-vm-service=0', join('lib', 'custom_lint_client.dart'), _serverSocket.address.host, _serverSocket.port.toString(),