oraios/serena · error · SvelteCompanionPreparationError
Failed to open {len(failed_svelte_files)} Svelte file(s) on
Error message
Failed to open {len(failed_svelte_files)} Svelte file(s) on companion TypeScript server: {listing} What it means
During startup the Svelte language server spawns a companion TypeScript server and opens every `.svelte` file on it so typescript-svelte-plugin adds them to the TS program. If any open_file call throws, the files are collected and this SvelteCompanionPreparationError is raised, listing up to _MAX_FAILED_FILES_IN_ERROR sorted paths (plus 'and N more'). The original first open error is attached as __cause__.
Source
Thrown at src/solidlsp/language_servers/svelte_language_server.py:383
failed_svelte_files = []
first_open_error: Exception | None = None
for svelte_file in svelte_files:
try:
with self._ts_server.open_file(svelte_file) as file_buffer:
file_buffer.ref_count += 1
self._indexed_svelte_file_uris.append(file_buffer.uri)
except Exception as exc:
log.debug("Failed to open %s on companion TS server: %s", svelte_file, exc)
if first_open_error is None:
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:View on GitHub (pinned to 7fcbca7e62)
Solutions
- Read the chained `__cause__` (first_open_error) in logs — it carries the real failure from the first file that could not be opened.
- Verify the companion TypeScript server is healthy: check that typescript-language-server and typescript were installed in the svelte-lsp-<version> dir and that node is on PATH.
- Reduce repo scope or move huge/generated .svelte trees (e.g. inside build output) out of the project; note node_modules and dot-dirs are already skipped.
- Check file permissions/readability of the listed .svelte files and that paths are valid on the current OS.
- Restart the language server session after fixing the underlying cause; the failure is collected at startup only.
Example fix
// before: unreadable files cause open_file to throw chmod 000 src/App.svelte // after chmod 644 src/App.svelte
Defensive patterns
Strategy: try-catch
Validate before calling
from pathlib import Path
svelte_files = [p for p in Path(repo).rglob("*.svelte")
if "node_modules" not in p.parts and os.access(p, os.R_OK)]
if not svelte_files:
print("nothing to index") # or investigate unreadable files before starting Type guard
def can_open_svelte_files(repo: str) -> bool:
return all(os.access(p, os.R_OK)
for p in Path(repo).rglob("*.svelte")
if "node_modules" not in p.parts) Try / catch
try:
server.start()
except SvelteCompanionPreparationError as e:
log.error("companion open failed: %s", e.__cause__)
# check tsserver process health, fix listed files, then restart
raise Prevention
- Read the __cause__ of SvelteCompanionPreparationError — it names the first failing file and reason
- Keep .svelte files readable and avoid exotic characters in paths
- Ensure node and the installed typescript-language-server binary are functional before startup
- Exclude generated/build .svelte output from the repo
- Monitor companion tsserver logs for crashes during startup
When it happens
Trigger: Starting the Svelte LS (which calls _start_typescript_server -> _ensure_svelte_files_indexed_on_ts_server) when `self._ts_server.open_file(svelte_file)` raises for one or more .svelte files — e.g. the companion tsserver process died, an LSP didOpen/didChange request timed out or returned an error, or the file buffer/URI handling failed.
Common situations: Companion TypeScript server crashed at startup (bad node, missing typescript-language-server binary) so every open fails; repo with unreadable or locked .svelte files; invalid characters in paths that break URI construction; tsserver request timeout under a huge repo; earlier companion preparation failures leaving the server in a bad state.
Related errors
- Companion TypeScript server did not finish indexing {len(sve
- Svelte companion TypeScript server did not become ready with
- Svelte companion TypeScript server project indexing did not
- {self._crash_message}
- Unhandled document change kind: {change}; Please report to S
AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29).
Data as JSON: /api/errors/56aebcd2dce6ad6f.
Report an issue: GitHub.