[Bug] OpenCode adapter leaks ChildProcess exit listeners until an LXC host freezes: "11 exit listeners added to [ChildProcess]"
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
Hướng nghiên cứu
Start by locating the OpenCode adapter’s ChildProcess exit listener registration and tracing how recoverShells, event-stream reconnects, and borrowed-session opens reuse child handles. Check whether listeners remain attached after exit or are added again to the same child; the issue does not name source files or tests. Done when repeated reconnect and retry paths do not accumulate exit listeners or retain exited child processes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[Bug] t3code.service leaks ChildProcess exit listeners until the whole LXC freezes: MaxListenersExceededWarning ... 11 exit listeners added to [ChildProcess]
Environment
- T3 Code Server
t3 serve --host 0.0.0.0 --base-dir /opt/t3code, systemd system unitt3code.service, Debian 13 inside an unprivileged Proxmox LXC (6 vCPU, 16 GiB), node v24.22.3 bundled SEA binary. - Reproduced on
0.1.10(npm view t3 dist-tags.latest= 0.1.10, so no stable upgrade exists). A test runtime0.1.11-nightly.20261119.4928was installed on 2026-11-19 08:32 EST to see whether it still leaks; results below. - Provider: OpenCode adapter (
opencode servechildren +opencode-pty).
What happened
The container froze completely twice on 2026-11-19 (06:44 and ~07:20 EST) and twice on 2026-11-17 (00:56, 04:16). Nothing self-healed: the guest journal goes silent roughly 20 minutes before a human has to force a stop/start from the Proxmox side (vzstop:4038:root@pam 07:07:45 + vzstart 07:07:52, again 08:07:58 + 08:08:12). Inside the guest the journal simply ends (06:49:04, 07:42:04) with no shutdown lines, and lxc-stop returns in ~3 s because all that RAM vanishes at once.
Numbers (container-scoped node_exporter, 5-min samples):
06:40 MemAvailable 7168 MiB AnonPages 2337 MiB Active_anon 967 MiB load1 4.5
06:45 MemAvailable 2925 MiB AnonPages 6552 MiB Active_anon 5581 MiB load1 13.5 procs_running 21
06:50 MemAvailable 780 MiB load1 77.7 procs_blocked 11
07:10 MemAvailable 4743 MiB (after a forced restart)
07:30 MemAvailable 563 MiB (growth resumed immediately)
While frozen, node_pressure_io_stalled_seconds_total and node_pressure_memory_stalled_seconds_total repeat identical values (06:44-06:52) - even node_exporter was blocked, which is why the guest stops logging while Proxmox still sees a live PID.
The signature points at ChildProcess exit listeners
The server logs itself, minutes before each cliff:
2026-11-19T05:13:56 t3[411515]: (node:411515) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [ChildProcess]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit
2026-11-19T06:44:00 t3[411515]: (node:411515) MaxListenersExceededWarning: ... same ...
2026-11-19T08:09:16 t3[404]: (node:404) MaxListenersExceededWarning: ... same ...
06:44:00 is five minutes before the 06:45 cliff. The same process also logs WARN (#9692): Lost the OpenCode event stream; reconnecting. (5 occurrences over 3 days) and a 54-line storm of
TimeoutError: Operation timed out after '5s'
at OpenCode2Adapter.recoverShells (file:///root/.t3/runtime/versions/0.1.10/t3:426721:50)
at OpenCode2Adapter.openSession (...:427739:19)
at OpenCode2Adapter.borrowAndOpenSession (...:431816:81)
at ProviderInstallationGate.execute (...:274260:45)
at orchestrationV2.providerTurnStart.start (...:363638:268)
so listeners appear to be re-added on every event-stream reconnect / recoverShells retry / borrowed-session open, on ChildProcess objects that stay referenced.
Growth is steep and starts from a cold idle start: after the 08:19:55 restart, systemctl show t3code -p MemoryCurrent -p MemoryPeak went 742 MiB -> 1.99 GiB MemoryPeak within 9 minutes, RSS being ~480 MiB in the node main process + ~330 MiB in one opencode child, with no thread doing heavy work. It is the top-RSS process in the container by 3x.
Ruled out on our side (so this is not a workload report)
- Disk: root 126 GiB with 23 GiB free (82 %).
- Host: hypervisor up 17 days, no
hung_task/ata/I/O-error kernel lines,smartctlPASSED on all three disks, no ZFS. - cgroup OOM:
/sys/fs/cgroup/lxc/4038/memory.eventsshowsoom 0 oom_kill 0- the kernel never killed anything, the box just thrashed (5.5 GiB of container swap in use). - Coredumps: none.
lxcfs:NRestarts=0. A per-unit sampler confirms the growth is insidet3code.service, not in any other service, and it is anonymous heap (not page cache, not/tmptmpfs, which stayed flat at 7355 MiB available across the cliff). - The OpenCode reconnect symptom matches closed #37396; the listener accumulation and the RAM growth do not appear to be covered there, and no existing issue mentions
exit listenersorChildProcesslisteners.
Asks
- Detach (or use
{once:true}for) theexitlisteners registered on OpenCode / providerChildProcesshandles when the child exits, and de-duplicate registration per child instead of per reconnect - the warning names the exact emitter, so it should be findable. - Consider a defensive
setMaxListenersonly as a symptom mask; the leak of the retainedChildProcess+ closure is the RAM cost, and 0.1.10 will happily reach the container limit. - Nice to have: log per-adapter retained-process counts (or expose them via a debug endpoint) so operators can attribute growth without a 3-day Prometheus history.
Workaround in place
/etc/systemd/system/t3code.service.d/memory-cap.conf = MemoryHigh=4G, MemoryMax=6G, OOMPolicy=stop, Restart=always, RestartSec=5, so the server is killed and back in ~5 s instead of freezing the whole container until someone presses Restart in the hypervisor UI. A V8 --max-old-space-size cap was rejected because the binary is a node SEA bundle and NODE_OPTIONS inheritance to its opencode children is not reliable.
- Ngôn ngữ chính
- TypeScript
- Star
- 24.8k
- Fork
- 6.4k
- Merge trung bình
- 4 giờ 29 phút
- Pull request đã merge (30 ngày)
- 488
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pingdotgg/t3code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs more info
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
pingdotgg/t3code#39400 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Wrapped PR titles lose bottom padding in the thread details panelCó thể đã có người làm @iamdatvt94 đã nhận 1 ngày trước. Đang mởbug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pingdotgg/t3code
Issue tương tự
-
area:plugins kind:bug priority:p2 ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Escaped `*` followed by `*` (`\**`) never matchesCó thể đã có người làm @bardrop đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 71/100
editorconfig/editorconfig-core-js#172 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
vega/vega-webgpu#40 ·
-
Adjust break point sizingĐang mởtype: bug 🐛
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
puckeditor/puck#1929 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
compression() compresses every response at Brotli quality 11Có thể đã có người làm @staylor đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày