{"record":{"id":"56aebcd2dce6ad6f","repo":"oraios/serena","slug":"failed-to-open-len-failed-svelte-files-svelte-f","errorCode":null,"errorMessage":"Failed to open {len(failed_svelte_files)} Svelte file(s) on companion TypeScript server: {listing}","messagePattern":"Failed to open (.+?) Svelte file\\(s\\) on companion TypeScript server: (.+?)","errorType":"exception","errorClass":"SvelteCompanionPreparationError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/svelte_language_server.py","lineNumber":383,"sourceCode":"\n        failed_svelte_files = []\n        first_open_error: Exception | None = None\n        for svelte_file in svelte_files:\n            try:\n                with self._ts_server.open_file(svelte_file) as file_buffer:\n                    file_buffer.ref_count += 1\n                    self._indexed_svelte_file_uris.append(file_buffer.uri)\n            except Exception as exc:\n                log.debug(\"Failed to open %s on companion TS server: %s\", svelte_file, exc)\n                if first_open_error is None:\n                    first_open_error = exc\n                failed_svelte_files.append(svelte_file)\n\n        if failed_svelte_files:\n            shown_files = sorted(failed_svelte_files)[:_MAX_FAILED_FILES_IN_ERROR]\n            remainder = len(failed_svelte_files) - len(shown_files)\n            listing = \", \".join(shown_files) + (f\" and {remainder} more\" if remainder else \"\")\n            raise SvelteCompanionPreparationError(\n                f\"Failed to open {len(failed_svelte_files)} Svelte file(s) on companion TypeScript server: {listing}\"\n            ) from first_open_error\n\n        self._svelte_files_indexed = True\n        log.info(\"Svelte file indexing complete; waiting for companion TS server to finish processing\")\n\n        timeout = self._get_companion_indexing_timeout()\n        if self._ts_server._wait_for_indexing_start_or_completion(timeout=timeout):\n            log.info(\"Companion TypeScript server finished indexing .svelte files\")\n        else:\n            raise TimeoutError(\n                f\"Companion TypeScript server did not finish indexing {len(svelte_files)} .svelte files within {timeout:.0f}s \"\n                f\"({self._ts_server.describe_indexing_state()})\"\n            )\n\n    def _cleanup_indexed_svelte_files(self) -> None:\n        \"\"\"Decrement ref-counts for all .svelte files opened during indexing.\"\"\"\n        if not self._indexed_svelte_file_uris or self._ts_server is None:","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/svelte_language_server.py#L365-L401","documentation":"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__.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: unreadable files cause open_file to throw\nchmod 000 src/App.svelte\n// after\nchmod 644 src/App.svelte","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nsvelte_files = [p for p in Path(repo).rglob(\"*.svelte\")\n                if \"node_modules\" not in p.parts and os.access(p, os.R_OK)]\nif not svelte_files:\n    print(\"nothing to index\")  # or investigate unreadable files before starting","typeGuard":"def can_open_svelte_files(repo: str) -> bool:\n    return all(os.access(p, os.R_OK)\n               for p in Path(repo).rglob(\"*.svelte\")\n               if \"node_modules\" not in p.parts)","tryCatchPattern":"try:\n    server.start()\nexcept SvelteCompanionPreparationError as e:\n    log.error(\"companion open failed: %s\", e.__cause__)\n    # check tsserver process health, fix listed files, then restart\n    raise","preventionTips":["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"],"tags":["svelte","typescript","companion-server","lsp","file-open"],"backgroundTag":"svelte-companion-preparation-failed","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}