Repository navigation
daemon: never let an internal git command wait on a credential prompt - #2459
ugoenyioha wants to merge 1 commit into
Conversation
The daemon inherited GIT_ASKPASS from the shell that started it (a Coder workspace sets it to its own credential bridge). A notes fetch from an HTTPS remote with no stored credentials ran that askpass program, which waited forever for a user. The fetch held one of the two command side-effect permits; the second hang took the other. Every family's queued side effects then accumulated in memory: 10,688 stalled families and 47 GB RSS after 10 hours on one workspace. - The daemon sets GIT_TERMINAL_PROMPT=0, GIT_ASKPASS='' (which also disables core.askPass and SSH_ASKPASS) and GCM_INTERACTIVE=never, and drops SSH_ASKPASS, for itself and every git it spawns. - Notes fetch and push abort an HTTP transfer slower than 1 KiB/s for 60 s instead of waiting on a stalled server. Tests: a local Basic-auth server plus an askpass program that never answers; the test fails (git hangs) when either the GIT_ASKPASS override or the whole environment is removed.
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| /// fetch blocked forever and stalled every family queued behind it. | ||
| #[cfg(unix)] | ||
| #[test] | ||
| fn daemon_git_env_fails_fast_on_credential_prompt() { |
There was a problem hiding this comment.
🟡 Daemon credential protection remains untested
If run_daemon omits make_git_noninteractive_for_daemon_process, this test still passes because it applies the constants directly. No TestRepo-based test covers the startup path, contrary to the repository's testing rule.
Learn more
The test builds a separate git ls-remote command and applies the same constants as the implementation. It does not exercise run_daemon, which is responsible for setting them in the daemon process. A regression that removes the startup call still passes the new test. The repository's integration-testing rule requires high-quality TestRepo-based coverage for Git behavior.
Example: Remove the make_git_noninteractive_for_daemon_process() call from daemon startup. The test still sets GIT_ASKPASS to an empty string on its own command and passes, even though a real daemon inherits an interactive askpass.
Recommended fix: Add a TestRepo-based integration test that starts a daemon with a hanging inherited askpass, runs a Git operation that triggers notes sync against a local authentication-challenging remote, and asserts the daemon finishes without launching askpass.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
|
Problem
The daemon inherits
GIT_ASKPASS(andSSH_ASKPASS/core.askPass) from the shell that starts it, and so does every git it spawns. Coder workspaces and VS Code remote sessions setGIT_ASKPASSto a credential bridge. When a pull triggers the daemon's notes sync against an HTTPS remote with no stored credentials, git runs that askpass, which waits forever for a user who isn't there.Each hung fetch holds one of the two command side-effect permits (
COMMAND_SIDE_EFFECT_CONCURRENCY = 2). Two of them stall every family. All subsequent work queues in memory: on one workspace there were 10,688 stalled families, 77,327 queued entries and 47 GB RSS after 10 hours. The two fetches were stuck onUsername for 'https://github.com'.Fix
GIT_TERMINAL_PROMPT=0,GIT_ASKPASS=(empty, which also stops git from falling back tocore.askPassandSSH_ASKPASS) andGCM_INTERACTIVE=never, and removesSSH_ASKPASS, for itself and all its git children.-c http.lowSpeedLimit=1024 -c http.lowSpeedTime=60, so a stalled server can't hold a permit indefinitely either.Tests
daemon_git_env_fails_fast_on_credential_prompt: a local Basic-auth server plus an askpass that never answers. With the daemon's env, git fails at once and never runs the askpass. Removing theGIT_ASKPASSoverride, or the whole env, makes git hang and the test fail (mutation-checked).authorship_fetch_and_push_args_abort_stalled_transfers.cargo test --lib: all pass;notes_sync_regression22 passed; integration notes/pull/fetch/push 168 passed.Field check
On the affected workspace, a
git pullfrom a credentialed server makes the daemon's notes fetch hit a 401:git-remote-httpblocked on the askpass.