oraios/serena · error · TypeScriptServerCrashedError

{self._crash_message}

Error message

{self._crash_message}

What it means

The TypeScript language server tracks tsserver's abnormal exit (via _tsserver_exit_message) and records a crash message. _raise_if_crashed re-checks this state at synchronization points (waiting for indexing to start/complete) and raises TypeScriptServerCrashedError with the recorded message, so a dead tsserver surfaces as a typed exception instead of a hang.

Source

Thrown at src/solidlsp/language_servers/typescript_language_server.py:142

        self.server_ready = threading.Event()
        self.initialize_searcher_command_available = threading.Event()

        # tracking asynchronous diagnostics publication
        self._published_diagnostics_timeout = 5.0

        # tracking project indexing progress
        self._progress_lock = threading.Lock()
        self._active_progress_tokens: set[str] = set()
        self._indexing_complete = threading.Event()
        self._indexing_complete.set()  # Initially set (no active work)
        # set from window/logMessage when tsserver reports its own abnormal exit;
        # a crash mid-indexing still drains _active_progress_tokens via a $/progress
        # "end" event, so that alone cannot distinguish a crash from real completion
        self._crash_message: str | None = None

    def _raise_if_crashed(self) -> None:
        if self._crash_message is not None:
            raise TypeScriptServerCrashedError(self._crash_message)

    @staticmethod
    def _tsserver_exit_message(msg: dict) -> str | None:
        """:return: the log text if ``msg`` is tsserver reporting its own abnormal exit, else None."""
        if msg.get("type") != MessageType.Error:
            return None
        message_text = str(msg.get("message", ""))
        if _TSSERVER_EXITED_PATTERN.search(message_text):
            return message_text
        return None

    def wait_for_indexing(self, timeout: float) -> bool:
        """Block until all $/progress tokens complete.

        :param timeout: Maximum seconds to wait.
        :return: True if indexing completed, False on timeout.
        :raises TypeScriptServerCrashedError: if tsserver reported an abnormal exit.
        """

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Read the recorded crash message in the exception to identify root cause (e.g. OOM, missing tsserver), then fix that cause.
  2. Recreate/restart the language server instance — a crashed tsserver process cannot be revived in place.
  3. For OOM crashes, raise the memory available to tsserver (e.g. NODE_OPTIONS=--max-old-space-size=8192) or exclude large generated directories via tsconfig.
  4. Pin/check the TypeScript version installed in the project and ensure node_modules is intact (`npm ci`).

Example fix

// before: reuse a server after crash
await server.wait_for_indexing()  // TypeScriptServerCrashedError
// after: catch and rebuild
try:
    await server.wait_for_indexing()
except TypeScriptServerCrashedError:
    server.stop()
    server = SolidLanguageServer.create("typescript")
    server.start()
    await server.wait_for_indexing()
Defensive patterns

Strategy: try-catch

Validate before calling

import subprocess
# ensure project's TypeScript install is intact before starting the server
subprocess.run(["npx", "tsc", "--version"], check=True, cwd=project_root)

Try / catch

try:
    await server.wait_for_indexing()
except TypeScriptServerCrashedError as e:
    logger.error("tsserver crashed: %s", e)
    server.stop()
    server = SolidLanguageServer.create("typescript")
    server.start()
    await server.wait_for_indexing()

Prevention

When it happens

Trigger: Calling wait_for_indexing or _wait_for_indexing_start_or_completion after tsserver reported its own abnormal exit (an Error-level tsserver log message indicating it crashed), at which point _crash_message is set and any wait invocation re-raises it.

Common situations: Out-of-memory kills of tsserver on very large monorepos; incompatible TypeScript version / corrupted node_modules; too many files exceeding tsserver limits; crashes after upgrading TypeScript or project dependencies mid-session.

Related errors


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