{"record":{"id":"b75d40dca78cef8d","repo":"oraios/serena","slug":"self-crash-message","errorCode":null,"errorMessage":"{self._crash_message}","messagePattern":"\\{self\\._crash_message\\}","errorType":"exception","errorClass":"TypeScriptServerCrashedError","httpStatus":null,"severity":"error","filePath":"src/solidlsp/language_servers/typescript_language_server.py","lineNumber":142,"sourceCode":"        self.server_ready = threading.Event()\n        self.initialize_searcher_command_available = threading.Event()\n\n        # tracking asynchronous diagnostics publication\n        self._published_diagnostics_timeout = 5.0\n\n        # tracking project indexing progress\n        self._progress_lock = threading.Lock()\n        self._active_progress_tokens: set[str] = set()\n        self._indexing_complete = threading.Event()\n        self._indexing_complete.set()  # Initially set (no active work)\n        # set from window/logMessage when tsserver reports its own abnormal exit;\n        # a crash mid-indexing still drains _active_progress_tokens via a $/progress\n        # \"end\" event, so that alone cannot distinguish a crash from real completion\n        self._crash_message: str | None = None\n\n    def _raise_if_crashed(self) -> None:\n        if self._crash_message is not None:\n            raise TypeScriptServerCrashedError(self._crash_message)\n\n    @staticmethod\n    def _tsserver_exit_message(msg: dict) -> str | None:\n        \"\"\":return: the log text if ``msg`` is tsserver reporting its own abnormal exit, else None.\"\"\"\n        if msg.get(\"type\") != MessageType.Error:\n            return None\n        message_text = str(msg.get(\"message\", \"\"))\n        if _TSSERVER_EXITED_PATTERN.search(message_text):\n            return message_text\n        return None\n\n    def wait_for_indexing(self, timeout: float) -> bool:\n        \"\"\"Block until all $/progress tokens complete.\n\n        :param timeout: Maximum seconds to wait.\n        :return: True if indexing completed, False on timeout.\n        :raises TypeScriptServerCrashedError: if tsserver reported an abnormal exit.\n        \"\"\"","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/oraios/serena/blob/7fcbca7e62555ec2287ddb2f083caee805848ea6/src/solidlsp/language_servers/typescript_language_server.py#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the recorded crash message in the exception to identify root cause (e.g. OOM, missing tsserver), then fix that cause.","Recreate/restart the language server instance — a crashed tsserver process cannot be revived in place.","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.","Pin/check the TypeScript version installed in the project and ensure node_modules is intact (`npm ci`)."],"exampleFix":"// before: reuse a server after crash\nawait server.wait_for_indexing()  // TypeScriptServerCrashedError\n// after: catch and rebuild\ntry:\n    await server.wait_for_indexing()\nexcept TypeScriptServerCrashedError:\n    server.stop()\n    server = SolidLanguageServer.create(\"typescript\")\n    server.start()\n    await server.wait_for_indexing()","handlingStrategy":"try-catch","validationCode":"import subprocess\n# ensure project's TypeScript install is intact before starting the server\nsubprocess.run([\"npx\", \"tsc\", \"--version\"], check=True, cwd=project_root)","typeGuard":null,"tryCatchPattern":"try:\n    await server.wait_for_indexing()\nexcept TypeScriptServerCrashedError as e:\n    logger.error(\"tsserver crashed: %s\", e)\n    server.stop()\n    server = SolidLanguageServer.create(\"typescript\")\n    server.start()\n    await server.wait_for_indexing()","preventionTips":["Give tsserver ample memory (NODE_OPTIONS=--max-old-space-size) for large projects.","Keep the project's TypeScript version consistent and node_modules intact.","Exclude generated/large directories from tsconfig to reduce tsserver load.","Always recreate the server instance after a crash; never reuse it."],"tags":["typescript","tsserver","crash","lsp","process-exit"],"backgroundTag":"language-server-crashed","analyzedSha":"7fcbca7e62555ec2287ddb2f083caee805848ea6","analyzedAt":"2026-08-29T00:04:09.619Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}