A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: probe LSP ports on loopback to avoid Windows firewall prompts (#11579)
Myles Scolnick2d547a36da0b
diff --git a/marimo/_server/lsp.py b/marimo/_server/lsp.pyindex c9fb0e8e20..091a15852e 100644--- a/marimo/_server/lsp.py+++ b/marimo/_server/lsp.py@@ -832,7 +832,8 @@ class CompositeLspServer(LspServer):self.config_reader = config_readerself.min_port = min_port- last_free_port = find_free_port(min_port)+ # Probing all interfaces can trigger the Windows firewall prompt.+ last_free_port = find_free_port(min_port, addr="127.0.0.1")# NOTE: we construct all servers up front regardless of whether they are enabled# in order to properly mount them as Starlette routes with their own ports@@ -842,7 +843,9 @@ class CompositeLspServer(LspServer):# We also need to ensure that the ports are uniqueself.servers: dict[str, LspServer] = {}for server_name, server_constructor in self.LANGUAGE_SERVERS.items():- last_free_port = find_free_port(last_free_port + 1)+ last_free_port = find_free_port(+ last_free_port + 1, addr="127.0.0.1"+ )self.servers[server_name] = server_constructor(last_free_port)def _is_enabled(self, config: MarimoConfig, server_name: str) -> bool:diff --git a/tests/_server/api/endpoints/test_lsp_endpoints.py b/tests/_server/api/endpoints/test_lsp_endpoints.pyindex 02472a0f57..af624ff10c 100644--- a/tests/_server/api/endpoints/test_lsp_endpoints.py+++ b/tests/_server/api/endpoints/test_lsp_endpoints.py@@ -235,7 +235,8 @@ class TestCompositeLspServer:"""Mock find_free_port to return incrementing ports."""port = [8000]- def side_effect(_: int) -> int:+ def side_effect(_: int, *, addr: str) -> int:+ assert addr == "127.0.0.1"port[0] += 1return port[0]diff --git a/tests/_server/test_lsp.py b/tests/_server/test_lsp.pyindex f3a9ed7a49..6fed56c192 100644--- a/tests/_server/test_lsp.py+++ b/tests/_server/test_lsp.py@@ -406,6 +406,23 @@ def test_copilot_server_node_version_validation():assert result is True # Should fail open+def test_composite_server_probes_loopback_ports():+ config_reader = get_default_config_manager(current_path=None)+ min_port = 8000+ num_servers = len(CompositeLspServer.LANGUAGE_SERVERS)+ ports = range(min_port, min_port + num_servers + 1)++ with mock.patch(+ "marimo._server.lsp.find_free_port", side_effect=ports+ ) as find_free_port:+ server = CompositeLspServer(config_reader, min_port=min_port)++ assert find_free_port.call_args_list == [+ mock.call(port, addr="127.0.0.1") for port in ports+ ]+ assert [lsp.port for lsp in server.servers.values()] == list(ports)[1:]++def test_composite_server():def as_reader(completion_config: CompletionConfig, config: LanguageServersConfig