Last 12 weeks · 0 commits
4 of 6 standards met
When both stdout and stderr are redirected and / are unset, falls through to . The current implementation opens and constructs a , but closes neither descriptor deterministically. On Linux, libuv normally reopens the TTY before attaching it to the stream handle. Consequently, each call can retain both the descriptor returned by and libuv’s reopened descriptor. One concrete trigger is an ink-based application running in a Docker container with a controlling TTY while its stdout and stderr are redirected inside the container. Ink falls back to terminal-size when terminal dimensions are unavailable and may invoke it repeatedly during rendering. Reproduction Using 4.0.1 on Node.js 24.18.0, Debian 12: Observed: The descriptors remained open after forced garbage collection and event-loop turns. Repeated calls can therefore exhaust the process’s descriptor limit and interfere with unrelated I/O. Cleanup complication The straightforward cleanup attempted in PR #27 was: 1. Retain the descriptor passed to . 2. Call . 3. Close the retained descriptor in a block. That is unsafe under descriptor pressure. libuv normally reopens the TTY, but if reopening fails, it retains the supplied descriptor. then closes that descriptor synchronously. Another native thread can reuse its number before the block calls , causing the latter to close an unrelated descriptor. The documented Node.js API does not expose whether libuv duplicated or retained the supplied descriptor, so the caller cannot safely decide which descriptors it still owns. Expected behavior Repeated calls should: Return the controlling terminal’s dimensions. Keep the process’s descriptor count stable. Never close unrelated descriptors under descriptor pressure. The regression test should run a redirected child inside a real pseudo-terminal in Linux CI rather than skipping when the CI process lacks a controlling TTY. This issue is Linux-specific. macOS follows a different libuv path and should be handled separately.
So trying to fix this issue I found that in this line of stops the execution: Reproduce With the binary, execute a script: And executing like this: This doesn't happen when you don't run the process in the background (so, without the last ): This could be an error in or in the binary, I have no clue.
Hey there, this is kind of a follow-up to #22. It works fine for the normal git bash window, however when opening e.g. a less pager in that window, it falls back to the default 80/24 values. I've debugged it and I think I found a bug, but I'd like your confirmation on this. STR 1. Comment out the following in the to simulate the pager without having to actually have a pager (line 60 is where we'd like to go): !grafik 2. Temporarily add the following to the bottom of the to execute the size function upon calling the script 3. Execute the in a Git Bash and see that it's not returning the correct window size. !grafik Possible Solution The index.js contains this line: !grafik The is duplicated and when I replace the second one with , it's working fine. !grafik Resulting in correct window sizes: !grafik Any opinion on this?
Repository: sindresorhus/terminal-size. Description: Reliably get the terminal window size Stars: 148, Forks: 17. Primary language: JavaScript. Languages: JavaScript (96.8%), TypeScript (3.2%). License: MIT. Latest release: v4.0.1 (6mo ago). Open PRs: 0, open issues: 2. Last activity: 6mo ago. Community health: 85%. Top contributors: sindresorhus, bndnsmth, coreyfarrell, BendingBender, fabiospampinato, ianobermiller, Richienb, rvagg, shinnn, styfle and others.