{"record":{"id":"aca12d9da045c0a6","repo":"BoundaryML/baml","slug":"could-not-start-the-playground-server","errorCode":null,"errorMessage":"could not start the playground server","messagePattern":"could not start the playground server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_lsp_server/src/lib.rs","lineNumber":688,"sourceCode":"\n    // The command line's roots are the host's own workspace folders:\n    // discovered now, before any client connects (a session that initializes\n    // later receives the standing diagnostics in full), and covering their\n    // projects for the life of the process. In editor mode they join whatever\n    // folders the client announces; in browser mode they are the only ones.\n    {\n        let roots = workspace_roots.clone();\n        runtime\n            .owner()\n            .post(OwnerEvent::Call(Box::new(move |state| {\n                for root in &roots {\n                    state.add_host_folder(root);\n                }\n            })));\n    }\n\n    let Some(listener) = playground_listener else {\n        anyhow::ensure!(\n            open_target == PlaygroundOpenTarget::LspClient,\n            \"could not start the playground server\"\n        );\n        return run_stdio_loop(&runtime, &writer_tx, &writer_budget, writer_rx, &lsp_sender);\n    };\n\n    if open_target == PlaygroundOpenTarget::Browser {\n        // Nothing drains `writer_rx` in browser mode (no stdout writer), so\n        // the bridge owns it and fans LSP output out to `/api/lsp`.\n        let lsp_out_tx_bridge = lsp_out_tx.clone();\n        std::thread::Builder::new()\n            .name(\"lsp-ws-bridge\".into())\n            .spawn(move || {\n                while let Ok(frame) = writer_rx.recv() {\n                    let _ = lsp_out_tx_bridge.send(frame);\n                }\n            })?;\n","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_lsp_server/src/lib.rs#L670-L706","documentation":"Raised via `anyhow::ensure!` in `run_server_inner`: the server was asked to open a playground target, but no playground listener could be started, and the open target requires more than the LSP client channel. Without a listener the playground cannot be served, so startup fails with this message.","triggerScenarios":"Starting the server with a playground open target that requires an HTTP playground server (not `PlaygroundOpenTarget::LspClient`) while `playground_listener` is `None` — i.e. playground server binding/startup failed or was not attempted.","commonSituations":"Port already in use so the playground listener could not bind; playground server disabled in configuration while an open-playground request targets the browser; misconfigured host/port for the playground.","solutions":["Check that the playground port is free and the listener bound successfully (look for bind errors earlier in the log)","Set the playground open target to `LspClient` if you only want the URL sent through the LSP client","Enable/fix the playground server configuration (host/port) so a listener can be created","Run `run_playground_server` explicitly if you intend a standalone playground server process"],"exampleFix":"// before: requiring browser-open with no listener\nlet Some(listener) = playground_listener else {\n    anyhow::ensure!(open_target == PlaygroundOpenTarget::LspClient,\n        \"could not start the playground server\");\n\n// after: fall back to the LSP client target when no listener is available\nlet open_target = if playground_listener.is_some() {\n    open_target\n} else {\n    PlaygroundOpenTarget::LspClient\n};\nlet Some(listener) = playground_listener else {\n    return run_stdio_loop(&runtime, &writer_tx, &writer_budget, writer_rx, &lsp_sender);\n};","handlingStrategy":"fallback","validationCode":"// check the playground port is bindable before startup\nstd::net::TcpListener::bind((host, port)).expect(\"playground port unavailable\");","typeGuard":null,"tryCatchPattern":"if playground_listener.is_none() {\n    eprintln!(\"playground server failed to start; falling back to LSP-client open target\");\n}","preventionTips":["Verify the playground host/port is free before launching the server","Default the open target to LspClient when running headless","Log listener bind errors distinctly from this ensure! failure"],"tags":["lsp","rust","playground","server-startup"],"backgroundTag":"connection-refused","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}