oraios/serena · error · TimeoutError

Request timed out ({timeout=})

Error message

Request timed out ({timeout=})

What it means

TimeoutError raised by LSPProcess.get_result when the result queue yields nothing within the given timeout. _send_request_once sends a request to the language-server subprocess and waits on a multiprocessing queue; if the server process never responds in time, the Empty queue exception is converted into this TimeoutError with the timeout value embedded.

Source

Thrown at src/solidlsp/ls_process.py:107

    def on_result(self, params: PayloadLike) -> None:
        self._status = "completed"
        self._result_queue.put(Request.Result(payload=params))

    def on_error(self, err: Exception) -> None:
        """
        :param err: the error that occurred while processing the request (typically an LSPError
            for errors returned by the LS or LanguageServerTerminatedException if the error
            is due to the language server process terminating unexpectedly).
        """
        self._status = "error"
        self._result_queue.put(Request.Result(error=err))

    def get_result(self, timeout: float | None = None) -> Result:
        try:
            return self._result_queue.get(timeout=timeout)
        except Empty as e:
            if timeout is not None:
                raise TimeoutError(f"Request timed out ({timeout=})") from e
            raise e


class LanguageServerInterface(ABC):
    """
    Represents an interface to a language server, providing methods for communicating with it using the
    Language Server Protocol (LSP).

    It provides methods for sending requests, responses, and notifications to the server
    and for registering handlers for requests and notifications from the server.

    Uses JSON-RPC 2.0 for communication with the server over stdin/stdout.
    """

    def __init__(
        self,
        ls_id: LanguageServerId,
        determine_log_level: Callable[[str], int],

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Retry with a larger timeout (or None) for slow servers / first-request indexing.
  2. Check whether the LSP subprocess is alive; if it crashed or hung, restart the SolidLanguageServer instance.
  3. Reduce workload: request symbols for smaller scopes/files, or warm up the server with a cheap request before time-sensitive calls.
  4. Capture the language server's stderr/log output to identify a hang or crash in the underlying LSP binary.

Example fix

// before
result = ls.request_document_symbols("huge/generated.ts", timeout=1.0)
// after
try:
    result = ls.request_document_symbols("huge/generated.ts", timeout=1.0)
except TimeoutError:
    result = ls.request_document_symbols("huge/generated.ts", timeout=60.0)
Defensive patterns

Strategy: retry

Validate before calling

import psutil
proc = getattr(ls, "_lsp_process", None)
if proc is not None and not proc.is_alive():
    raise RuntimeError("LSP subprocess dead; restart the server before issuing requests")

Try / catch

try:
    result = call_api(..., timeout=timeout_s)
except TimeoutError:
    result = call_api(..., timeout=timeout_s * 4)  # retry with backoff and larger timeout

Prevention

When it happens

Trigger: Calling any request API with a timeout shorter than the server's response time (huge files, cold-start indexing), a hung/crashed LSP subprocess, or requests sent to a server busy with a long operation (e.g. initial project indexing).

Common situations: Large monorepos where the first request times out during startup indexing, language-server binary hanging (known issues with some LSPs on big files), system resource starvation slowing the subprocess, or a dead subprocess after a crash so no result ever arrives.

Understand the failure class

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/0b9bb5583d3cdbe4. Report an issue: GitHub.