oraios/serena · error · TimeoutError

Companion TypeScript server did not finish indexing {len(sve

Error message

Companion TypeScript server did not finish indexing {len(svelte_files)} .svelte files within {timeout:.0f}s ({self._ts_server.describe_indexing_state()})

What it means

After opening all .svelte files on the companion TypeScript server, the Svelte LS waits (bounded by the `indexing_timeout` setting, default from SvelteTypeScriptServer.INDEXING_PROGRESS_TIMEOUT) for tsserver to report indexing start/completion via project-wide diagnostics/progress. If `_wait_for_indexing_start_or_completion` returns False, this TimeoutError is raised including the file count, the timeout, and the server's `describe_indexing_state()` snapshot for diagnosis.

Source

Thrown at src/solidlsp/language_servers/svelte_language_server.py:394

                    first_open_error = exc
                failed_svelte_files.append(svelte_file)

        if failed_svelte_files:
            shown_files = sorted(failed_svelte_files)[:_MAX_FAILED_FILES_IN_ERROR]
            remainder = len(failed_svelte_files) - len(shown_files)
            listing = ", ".join(shown_files) + (f" and {remainder} more" if remainder else "")
            raise SvelteCompanionPreparationError(
                f"Failed to open {len(failed_svelte_files)} Svelte file(s) on companion TypeScript server: {listing}"
            ) from first_open_error

        self._svelte_files_indexed = True
        log.info("Svelte file indexing complete; waiting for companion TS server to finish processing")

        timeout = self._get_companion_indexing_timeout()
        if self._ts_server._wait_for_indexing_start_or_completion(timeout=timeout):
            log.info("Companion TypeScript server finished indexing .svelte files")
        else:
            raise TimeoutError(
                f"Companion TypeScript server did not finish indexing {len(svelte_files)} .svelte files within {timeout:.0f}s "
                f"({self._ts_server.describe_indexing_state()})"
            )

    def _cleanup_indexed_svelte_files(self) -> None:
        """Decrement ref-counts for all .svelte files opened during indexing."""
        if not self._indexed_svelte_file_uris or self._ts_server is None:
            return
        log.debug("Cleaning up %d indexed .svelte files", len(self._indexed_svelte_file_uris))
        for uri in self._indexed_svelte_file_uris:
            try:
                if uri in self._ts_server.open_file_buffers:
                    file_buffer = self._ts_server.open_file_buffers[uri]
                    file_buffer.ref_count -= 1
                    if file_buffer.ref_count == 0:
                        self._ts_server.server.notify.did_close_text_document({"textDocument": {"uri": uri}})
                        del self._ts_server.open_file_buffers[uri]
            except Exception as exc:

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Raise `indexing_timeout` in the svelte LS-specific settings (or the TYPESCRIPT ls settings): e.g. {"indexing_timeout": 300}.
  2. Inspect the `describe_indexing_state()` text in the message — it tells whether indexing never started, was in progress, or stalled.
  3. Reduce the number of .svelte files tsserver must process (exclude generated/dist trees, split the repo).
  4. Ensure node/tsserver has adequate CPU and memory; check tsserver logs for crashes or OOM.
  5. Retry after fixing; the timeout is a startup-time wait, not a permanent state.

Example fix

// before (default timeout too small for a monorepo)
settings = {}
// after
settings = {"ls_specific_settings": {"svelte": {"indexing_timeout": 300}}}
Defensive patterns

Strategy: validation

Validate before calling

repo = Path(repo_path)
svelte_count = sum(1 for p in repo.rglob("*.svelte")
                   if "node_modules" not in p.parts)
# scale the timeout to the repo size before configuring the LS
settings["ls_specific_settings"]["svelte"] = {
    "indexing_timeout": max(120, svelte_count * 0.5)
}

Try / catch

try:
    server.start()
except TimeoutError as e:
    if "did not finish indexing" in str(e):
        # state snapshot is embedded in the message; raise timeout or retry once
        log.warning("companion indexing slow: %s", e)
        server = retry_with_longer_timeout()
    else:
        raise

Prevention

When it happens

Trigger: Calling _start_typescript_server (startup of the Svelte LS) when the companion tsserver never signals indexing completion within `indexing_timeout` seconds — typically with very large .svelte trees, a slow/hung tsserver, or progress events not observed.

Common situations: Monorepos with thousands of .svelte files exhausting tsserver; low CPU/memory making tsserver slow; a hung or crashed tsserver process; TypeScript project misconfiguration causing the plugin never to finish; setting `indexing_timeout` (svelte-specific or typescript ls-specific settings) too low for the repo size.

Understand the failure class

Related errors


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