feat: auto-restart crashed LS with exponential backoff (#163 by @you922)
* feat: auto-restart crashed language server with exponential backoff When a language server instance crashes, the proxy now automatically respawns it after a brief backoff instead of leaving downstream requests hanging with ECONNRESET / ERR_HTTP2_CONNECT errors. Implementation: - scheduleLsRestart() in langserver.js with configurable exponential backoff (base: 1s → 2s → 4s → 8s) - Per-key retry counter to prevent infinite loops on permanent errors - Env-configurable: LS_AUTO_RESTART, LS_AUTO_RESTART_MAX_RETRIES, LS_AUTO_RESTART_BASE_DELAY_MS - getRestartStats() for monitoring restart health - All timeouts use .unref() to not block process exit Configuration: LS_AUTO_RESTART=1 # default: on LS_AUTO_RESTART_MAX_RETRIES=3 # default: 3 LS_AUTO_RESTART_BASE_DELAY_MS=1000 # default: 1000ms Fixes: #157 * fix: prevent auto-restart on intentional LS shutdown (Oracle review) Added _intentionalShutdown Set to track LS instances being shut down deliberately via stopLanguageServer() or restartLsForProxy(). Without this, the exit handler unconditionally fires scheduleLsRestart for every killed process, spawning unwanted LS instances. Changes: - _intentionalShutdown Set prevents restart for intentional kills - restartLsForProxy marks key before process.kill - stopLanguageServer marks all keys before kill loop - Exit handler checks Set before calling scheduleLsRestart - Cleanup after exit check (prevents set growth) --------- Co-authored-by: Chen Jiangjiang <chenjiangjiang@kt51.cc>
Y
you922 committed
81e249b613803336b709939adf41c9c4d445bb8d
Parent: 1c21c0e
Committed by GitHub <noreply@github.com>
on 5/12/2026, 2:47:09 AM