Skip to main content

Module bounded_push

Module bounded_push 

Source
Expand description

The auto-push’s real git push with a deadline, its low-speed abort and the lock wait limit derived from it. What: Run the auto-push’s real git push with a deadline, and derive the wait limits the push coordination uses. Why: A push whose connection stalls would otherwise hold the branch’s push lock forever, and every later commit on that branch would wait behind it. The push is stopped when its deadline passes, the commit stays saved locally, and the failure is recorded like any other failed push.

In TS you’d write (pseudocode):

const { exitCode, output } = await nanoSpawn(gitPath, pushArgs, { cwd, signal: AbortSignal.timeout(deadlineMs) });

Enums§

StopCause
Why a push or query was stopped.

Constants§

DEFAULT_PUSH_DEADLINE
How long a push may run when the variable is absent or unusable.
LOCK_WAIT_MARGIN
Extra time a waiter gives the lock holder beyond the holder’s whole push, so a holder that runs to its own deadline is outwaited.
LOCK_WAIT_VARIABLE
Environment variable that sets how long to wait for another invocation’s push lock, in whole seconds.
LOW_SPEED_LIMIT
Lowest transfer speed in bytes per second Git tolerates on an HTTP transfer.
LOW_SPEED_TIME
Seconds the transfer may stay below the lowest speed before Git aborts it.
MAX_PUSH_OUTPUT
The most output bytes kept from one push; a push that writes more is stopped.
PUSH_DEADLINE_VARIABLE
Environment variable that sets the push deadline in whole seconds.
STOPPED_EXIT_CODE
Exit code recorded for a push that this wrapper stopped, the convention of timeout(1).
STOP_GRACE
How long a stopped push gets to end after the polite stop signal before it is killed.

Functions§

apply_low_speed_defaults
What: Add Git’s low-speed abort to a push command unless the environment sets it. Why: Git ends an HTTP transfer that stays under the limit for the time, which also ends its helper processes; the push deadline is only the backstop for transports this does not cover. Git lets these variables override http.lowSpeedLimit and http.lowSpeedTime from its configuration, so only a person’s environment variables are kept, not their configuration.
lock_wait_limit
What: How long a process waits for another invocation’s push lock: the environment’s value, or the push deadline plus the stop grace plus a margin. Why: The holder may run its whole push deadline and then needs the stop grace to end, so the default waiter outlasts a holder that is merely slow before it reports the lock as stuck.
positive_seconds
What: Read a positive whole number of seconds from one environment value. Why: A zero, negative, fractional, empty or non-text value is no setting at all, never “no limit”, so a typo cannot remove a bound.
push_deadline
What: The push deadline: the environment’s value, or the default. Why: A person may need a longer deadline on a slow link or a shorter one on a flaky one.
run_bounded_push
What: Run a push command to its end or its deadline and capture its interleaved output. Why: Both streams share one anonymous file so lines keep the order Git wrote them, and a file needs no reader thread that a stuck helper could keep alive. A stopped push becomes a failed attempt that says so, so the commit stays saved and the failure is recorded for later invocations.
stop_push
What: Stop a running push: ask politely, wait the grace, then kill and collect it. Why: Git’s own signal handling ends the helpers it started, and a push that ignores the request cannot outlive the kill.
strip_one_line_break
Remove exactly one trailing \n or \r\n, as the captured output of the incumbent does.
wait_until_done
What: Look at a running push until it ends, its deadline passes or its output floods. Why: std has no timed wait, so the parent looks with try_wait, which never blocks.