Skip to content

fix(telemetry): prevent tzutil console flash on Windows#13353

Merged
williammartin merged 1 commit into
cli:trunkfrom
adehad:fix/telemetry-windows-console-flash
May 13, 2026
Merged

fix(telemetry): prevent tzutil console flash on Windows#13353
williammartin merged 1 commit into
cli:trunkfrom
adehad:fix/telemetry-windows-console-flash

Conversation

@adehad

@adehad adehad commented May 6, 2026

Copy link
Copy Markdown

Fixes #13354

Summary

On Windows, every gh invocation that records telemetry produces a brief console window flash. The flash is tzutil.exe /g being spawned by the gh send-telemetry subprocess to resolve the local IANA timezone (via the transitive dependency github.com/thlib/go-timezone-local).

With Windows Terminal configured to keep windows open after exit (e.g. closeOnExit: never), these conhost instances accumulate.

Root cause

internal/telemetry/detach_windows.go spawns the telemetry subprocess with DETACHED_PROCESS. Per the Win32 process creation flags reference:

  • DETACHED_PROCESS — child has no console at all. Any console-subsystem descendant (tzutil.exe) then allocates a fresh conhost on first stdio access, producing the visible flash.
  • CREATE_NO_WINDOW — child runs as a console application without a visible console window. Descendants inherit the non-visible console and don't allocate a new one.

DETACHED_PROCESS and CREATE_NO_WINDOW are mutually exclusive. CREATE_NEW_PROCESS_GROUP remains compatible with the chosen flag.

Reproduction

Captured process tree on Windows 11:

gh.exe (parent shell invocation)
└── gh.exe send-telemetry    (spawned with DETACHED_PROCESS — no console)
    └── tzutil.exe /g        (allocates fresh conhost — visible flash)

gh send-telemetry invokes tzlocal.localTZfromTzutil() from github.com/thlib/go-timezone-local, which performs exec.Command("tzutil", "/g") with no Windows-specific window-suppression flags — so the inherited (absent) console determines visibility.

Fix

Replace DETACHED_PROCESS with CREATE_NO_WINDOW. Single-line behavioural change plus an explanatory comment.

@adehad adehad requested a review from a team as a code owner May 6, 2026 10:52
@adehad adehad requested a review from williammartin May 6, 2026 10:52
@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed ready-for-review and removed needs-triage needs to be reviewed labels May 6, 2026
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

Thanks for your pull request! While it doesn't meet all of our standard requirements, it appears to be a small, focused contribution and has been routed to the team for review.

Note: We still encourage linking to an issue with the help wanted label when possible, as it helps us prioritize and track contributions.

…on Windows

DETACHED_PROCESS leaves the gh send-telemetry child with no console at
all. When the transitive dependency thlib/go-timezone-local invokes
`tzutil /g` to resolve the local IANA timezone, the console-subsystem
tzutil binary allocates a fresh conhost — producing a visible window
flash on every gh invocation, which accumulates as orphan terminals
under terminal configurations that keep windows open on exit.

CREATE_NO_WINDOW gives the child a non-visible console that descendants
inherit, suppressing the flash. CREATE_NEW_PROCESS_GROUP is preserved
so Ctrl+C still does not propagate to the detached telemetry child.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@williammartin williammartin merged commit 1e6bb88 into cli:trunk May 13, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team ready-for-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tzutil console window flash on every gh invocation (Windows)

2 participants