Language server (tsc --lsp) exits with code 1 after `shutdown` and `exit`
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 76/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- go
- Bereich
- backend-api-design, devtools
Rechercherichtung
Beginne in tsc/internal/lsp/server.go und verfolge den Pfad des Issues durch handleExit, dispatchLoop und Run; lies anschließend tsc/cmd/tsc/lsp.go, wo der Fehler zum Exit-Code 1 wird. Reproduziere das Problem mit dem bereitgestellten repro.py, sowohl mit als auch ohne geöffnetes Dokument. Als erledigt gilt die Arbeit, wenn ein reguläres shutdown gefolgt von exit den Code 0 zurückgibt und das im Issue beschriebene Verhalten bei unerwartetem Beenden erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
🔎 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
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 16.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 193
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/TypeScript
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
microsoft/TypeScript#64758 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Class names `eval` and `arguments` are not reported as invalid strict mode bindingsEvtl. vergeben @dmety hat das vor 8 Tagen übernommen. OffenBug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoft/TypeScript#64661 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Non-enum CLI options with multiple values separated by comma and space aren't whitespace trimmedEvtl. vergeben @RyanCavanaugh hat das vor 9 Tagen übernommen. OffenBug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
microsoft/TypeScript#64618 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
TypeScript 7 VS Code extension: a workspace "typescript" 7.x package is not detected, only "@typescript/native-preview", which is no longer publishedEvtl. vergeben @jakebailey hat das vor 9 Tagen übernommen. OffenNeeds Investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microsoft/TypeScript#64565 · 1 Reaktion · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
`EFNoLeadingComments` suppresses synthesized leading comments in tsgo; Strada only suppresses source commentsEvtl. vergeben @weswigham hat das vor 16 Tagen übernommen. OffenNeeds Investigation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
microsoft/TypeScript#64453 · 1 Kommentar · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoft/TypeScript
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
documentation hacktoberfest priority: low skill: good first issue status: ready for dev
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 85/100
hyperledger-labs/fabric-smart-client#2142 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
numberly/vault-db-injector#107 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/import kind/bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
Maintainer antworten meist innerhalb von 1 Tag
-
[DOC] Wrong sg_egress_ports range in the Terraform Databricks Guide for AWS Hub & Spoke with Network FirewallEvtl. vergeben @akhil9tiet hat das heute übernommen. Offendocs
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
databricks/terraform-provider-databricks#6080 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 3 Tagen