Windows/ConPTY: writing to a killed pty emits EAGAIN on an untended inSocket -> uncaught exception
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 74/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- node.js, typescript
- Domaine
- operating-systems
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- TypeScript
- Étoiles
- 2k
- Forks
- 341
- Merge moyen
- 1 j 1 h
- PR mergées (30 j)
- 7
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/node-pty
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
ConPTY/TSFN exit callback aborts the process during environment teardown — fixable with NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS (same root cause as #904)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
microsoft/node-pty#951 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Windows: conin socket has no 'error' listener, so a failed pty write is an uncaught exceptionOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de microsoft/node-pty
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
lukilabs/beautiful-mermaid#160 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
rescript-lang/rescript-lang.org#1420 ·
Les mainteneurs répondent en général sous 2 jours
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
chthollyphile/folia-major#520 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
databuddy-analytics/Databuddy#1106 ·
Les mainteneurs répondent en général sous 1 jour