Windows/ConPTY: writing to a killed pty emits EAGAIN on an untended inSocket -> uncaught exception
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 74/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- node.js, typescript
- Bereich
- operating-systems
Rechercherichtung
Start with WindowsPtyAgent._inSocket in windowsPtyAgent.js around line 82, then compare the error handling in windowsTerminal.js around line 80 and IPty's _forwardEvents path. Run the minimal Node/ConPTY reproduction on Windows and verify that writing after p.kill() no longer produces an uncaught exception, with the failure either dropped or exposed through the public API.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Environment: node-pty 1.1.0 · Windows 11 (26200) · ConPTY (useConpty: true, non-DLL path) · reproduced on Node 22.x
Description
On Windows, writing to a pty's stdin (conin) shortly after its child process has exited fails asynchronously with write EAGAIN. The write goes to WindowsPtyAgent._inSocket, which is created without any 'error' listener (windowsPtyAgent.js ~L82). The 'error' handler in windowsTerminal.js (L80) is attached to _socket = _agent.outSocket (the read side), not the write side. So the socket emits 'error' with no listener and the process throws:
Error: write EAGAIN
at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:87:19)
This is not catchable by the caller: IPty.write() returns normally and the failure surfaces later on the write-completion callback. IPty does not forward inSocket errors (_forwardEvents only wires _socket/outSocket), so a consumer cannot subscribe through the public API either.
Minimal repro (Node, no Electron)
const pty = require('node-pty')
const p = pty.spawn('cmd.exe', ['/k', 'echo hi'], { useConpty: true, cols: 80, rows: 24 })
setTimeout(() => { p.kill(); setTimeout(() => p.write('x'), 2000) }, 800)
// ~a couple seconds later: uncaught "write EAGAIN" from the inSocket
Timing-dependent: the conin pipe's 128 KB buffer stays writable briefly after death, then rejects with EAGAIN.
Expected
A write to a dead pty's stdin is dropped or surfaced as a catchable error — never an uncaught exception.
Suggested fix
Attach an 'error' handler to _inSocket (mirroring the outSocket handler), and/or forward its errors through IPty so consumers can handle them.
Downstream report
obogoni/playground#103
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.1k
- Forks
- 349
- Ø Merge
- 1 T. 11 Std.
- Gemergte PRs (30 T.)
- 7
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine 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/node-pty
-
spawn drops an own `__proto__` environment entryEvtl. vergeben @nikolay-dementiev hat das vor 10 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
ConPTY/TSFN exit callback aborts the process during environment teardown — fixable with NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS (same root cause as #904)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/node-pty#951 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoft/node-pty
Ähnliche Issues
-
a10y a10y-audit ai-driven-qa claude
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
linagora/twake-directory-manager#219 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
Maintainer antworten meist innerhalb von 1 Tag
-
0️⃣ phase/new
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Pulse v7: buildPreferencesFromTelos() bypasses telosSectionOrFile(), renders empty on unified-TELOS installsEvtl. vergeben @zephyr91 hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
danielmiessler/LifeOS#2393 ·
Maintainer antworten meist innerhalb von 4 Tagen