Windows/ConPTY: writing to a killed pty emits EAGAIN on an untended inSocket -> uncaught exception
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 2k
- 派生
- 341
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/node-pty 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
ConPTY/TSFN exit callback aborts the process during environment teardown — fixable with NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS (same root cause as #904)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/node-pty#951 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
查看 microsoft/node-pty 的全部 Issue
相似的 Issue
-
[Docs] README: FAQ setup command, IDA in the intro, Node badge可能已有人在做 @akram1089 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
[Feature]: [P3] engine-rs: the package source hash should ignore line endings and untracked files未关闭
难度 2/5 1-3 小时 新手友好度 70/100
maniator/verticopolis#880 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 62/100
siyuan-note/siyuan#20353 ·
维护者通常 1 天内回复
-
afk-ok area:data-quality importer size:S
难度 2/5 1-3 小时 新手友好度 82/100
enorm-labs/event-junkie#3027 ·
维护者通常 1 天内回复