Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- go
- Ambito
- backend-api-design, devtools
Direzione di ricerca
Inizia da tsc/internal/lsp/server.go, seguendo il percorso dell’issue attraverso handleExit, dispatchLoop e Run; poi leggi tsc/cmd/tsc/lsp.go, dove l’errore diventa il codice di uscita 1. Riproduci il problema con il repro.py fornito, sia con un documento aperto sia senza. Il lavoro è completo quando un shutdown regolare seguito da exit restituisce il codice 0, mentre il comportamento di uscita imprevista descritto nell’issue rimane invariato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
🔎 Search Terms
tsc --lsp exit code 1, shutdown exit, context canceled, handleExit io.EOF, LSP exit notification
🕗 Version & Regression Information
- I was unable to test this on prior versions because
--lspis new in TypeScript 7: seen withtypescript7.0.2 (tsc --lsp --stdio), macOS arm64. I have not run the nightly; the code path below is unchanged onmainat aa81492.
⏯ Playground Link
No response (language server, not type checking)
💻 Code
Save as repro.py and run python3 repro.py in any directory. It initializes tsc --lsp --stdio, sends shutdown, then exit, and prints the exit code (given a URI, it opens a document first; no argument opens nothing).
# python3 repro.py [URI to open], in a directory with a tsconfig.json
import json, os, subprocess, sys
p = subprocess.Popen(["tsc", "--lsp", "--stdio"], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
def send(msg):
body = json.dumps({"jsonrpc": "2.0", **msg}).encode()
p.stdin.write(b"Content-Length: %d\r\n\r\n%s" % (len(body), body))
p.stdin.flush()
def reply(id):
while True:
length = None
while (line := p.stdout.readline()) not in (b"\r\n", b""):
if line.lower().startswith(b"content-length:"):
length = int(line.split(b":")[1])
if length is None:
return None # the server is gone
msg = json.loads(p.stdout.read(length))
if "method" in msg and "id" in msg: # a request from the server
send({"id": msg["id"], "result": None})
elif msg.get("id") == id:
return msg
root = "file://" + os.getcwd()
send({"id": 1, "method": "initialize", "params": {"processId": os.getpid(), "rootUri": root, "capabilities": {}}})
reply(1)
send({"method": "initialized", "params": {}})
if len(sys.argv) > 1:
doc = {"uri": sys.argv[1], "languageId": "typescript", "version": 0, "text": "const x = 1;\n"}
send({"method": "textDocument/didOpen", "params": {"textDocument": doc}})
send({"id": 2, "method": "shutdown"})
if reply(2) is not None:
send({"method": "exit"})
print("exit code:", p.wait())
🙁 Actual behavior
$ python3 repro.py
context canceled
exit code: 1
The server exits with code 1 after a clean shutdown and exit. Neovim reports any non-zero exit, so every :lsp restart shows "Client tsc quit with exit code 1 and signal 0. Check log for errors".
Reading main at aa81492, the path looks like this:
handleExitreturnsio.EOF.dispatchLoopanswers that withlspExit(nil), which cancels the loop's context.- Its next
s.requestQueue.Get(ctx)then returnscontext.Canceled, and the loop returns that. Runpasses it on, since it isn'tio.EOFand the group's context is done.cmd/tsc/lsp.goprints it and returns 1.
🙂 Expected behavior
Exit code 0: the LSP spec asks for 0 when shutdown came before exit, and 1 otherwise.
Additional information about the issue
No response
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 16.4k
- Merge medio
- 1g 16h
- PR unite (30g)
- 154
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/TypeScript
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/TypeScript#64758 ·
I maintainer di solito rispondono entro 1 giorno
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsForse già presa @dmety l’ha presa 6 giorni fa. ApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoft/TypeScript#64661 ·
I maintainer di solito rispondono entro 1 giorno
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedForse già presa @RyanCavanaugh l’ha presa 7 giorni fa. ApertaBug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
microsoft/TypeScript#64618 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
TypeScript 7 VS Code extension: a workspace "typescript" 7.x package is not detected, only "@typescript/native-preview", which is no longer publishedForse già presa @jakebailey l’ha presa 7 giorni fa. ApertaNeeds Investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/TypeScript#64565 · 1 reazione · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
`EFNoLeadingComments` suppresses synthesized leading comments in tsgo; Strada only suppresses source commentsForse già presa @weswigham l’ha presa 14 giorni fa. ApertaNeeds Investigation
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/TypeScript#64453 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/TypeScript
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
chaitin/agent-compose#770 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
kubernetes-sigs/vsphere-csi-driver#4351 ·
I maintainer di solito rispondono entro 1 giorno
-
component/gpu-kubelet-plugin component/helm needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
kubernetes-sigs/dra-driver-nvidia-gpu#1559 ·
I maintainer di solito rispondono entro 1 giorno
-
workflow: redundant goroutine in scheduleRetryForse già presa @moodbased l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni