Skip to content

Set TERM=dumb under PTY to prevent capability-probe hangs#1363

Merged
j178 merged 3 commits intoj178:masterfrom
yihong0618:hy/close_issue_1362
Jan 15, 2026
Merged

Set TERM=dumb under PTY to prevent capability-probe hangs#1363
j178 merged 3 commits intoj178:masterfrom
yihong0618:hy/close_issue_1362

Conversation

@yihong0618
Copy link
Contributor

close #1362

…o timeout issue

Signed-off-by: yihong0618 <zouzou0208@gmail.com>
@github-actions
Copy link

github-actions bot commented Jan 15, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (22.3 MiB → 22.3 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 71.9KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 53.3KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.4KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 47.0KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.4KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.7KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 29.2KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.3% 27.6KiB         prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 21.5KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.3KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.1KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.2KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.6%  91.8%  8.1MiB              And 19605 smaller methods. Use -n N to show more.
39.9% 100.0%  8.9MiB              .text section size, the file size is 22.3MiB

Base Branch Results

 File  .text    Size        Crate Name
 0.3%   0.8% 71.9KiB        prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.2%   0.6% 53.3KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 49.4KiB         prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 47.0KiB         prek prek::run::{{closure}}
 0.2%   0.5% 42.4KiB         prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 35.1KiB         prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.1%   0.3% 31.7KiB        prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 29.2KiB  serde_json? <&mut serde_json::de::Deserializer<R> as serde_core::de::Deserializer>::deserialize_struct
 0.1%   0.3% 27.6KiB         prek prek::identify::by_extension::{{closure}}
 0.1%   0.2% 21.5KiB         prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 21.3KiB clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.3KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.1KiB         prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 19.6KiB         prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.2KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.9KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
 0.1%   0.2% 18.6KiB         ring ring_core_0_17_14__x25519_ge_frombytes_vartime
 0.1%   0.2% 18.2KiB   hyper_util hyper_util::client::legacy::client::Client<C,B>::send_request::{{closure}}
 0.1%   0.2% 18.1KiB    [Unknown] fe_loose_invert
 0.1%   0.2% 17.7KiB         prek prek::cli::run::filter::collect_files_from_args::{{closure}}
36.6%  91.8%  8.1MiB              And 19606 smaller methods. Use -n N to show more.
39.9% 100.0%  8.9MiB              .text section size, the file size is 22.3MiB

@codecov
Copy link

codecov bot commented Jan 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.11%. Comparing base (34fb8f3) to head (bb2dd6d).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1363   +/-   ##
=======================================
  Coverage   90.11%   90.11%           
=======================================
  Files          80       80           
  Lines       15927    15928    +1     
=======================================
+ Hits        14353    14354    +1     
  Misses       1574     1574           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@j178 j178 changed the title fix: add env color to fake in child stdin like a real tty to ignore timeout issue Set TERM=dumb under PTY to prevent capability-probe hangs Jan 15, 2026
@j178 j178 added the bug Something isn't working label Jan 15, 2026
@j178
Copy link
Owner

j178 commented Jan 15, 2026

Thanks @yihong0618 for debugging and the quick fix! Do you think setting TERM=dumb might make more sense?

@yihong0618
Copy link
Contributor Author

Thanks @yihong0618 for debugging and the quick fix! Do you think setting TERM=dumb might make more sense?

yep cpython also use something like this name

@j178 j178 merged commit 639fc48 into j178:master Jan 15, 2026
19 checks passed
@yihong0618
Copy link
Contributor Author

j178 added a commit that referenced this pull request Feb 6, 2026
Closes #1561
Previous fix: #1363

We run subcommands under a PTY so they behave like they do in an
interactive terminal (colors, progress bars, etc.). However, this is
still a *pseudo*-terminal and it doesn't necessarily provide a
full/accurate terminal environment.

Some libraries (for example Go's termenv) send OSC/CSI queries and wait
for a response from the terminal. Our PTY doesn't emulate those
responses, so they can block on a timeout if the program insists on
probing capabilities.

Previously, we tried to work around this by setting `TERM=dumb` in the
environment, but that caused other issues (for example, some programs
(e.g cargo), disable color entirely when they see `TERM=dumb`, even if
the output is actually a terminal that supports color).

We intentionally do not make the child a session leader/foreground
process group here. When we did, termenv detected it as foreground and
ran OSC probes, which then hung.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long latency with treefmt

2 participants