gitea
gitea copied to clipboard
Use request timeout for git service rpc
This enables git.Command's Run to optionally use the given context directly so its deadline will be respected. Otherwise, it falls back to the previous behavior of using the supplied timeout or a default timeout value of 360 seconds.
repo's serviceRPC() calls now use the context's deadline (which is unset/unlimited) instead of the default 6-minute timeout. This means that large repo clones will no longer arbitrarily time out on the upload-pack step, and pushes can take longer than 6 minutes on the receive-pack step.
Fixes #20680
@wxiaoguang let me know if this is what you had in mind. I think this is going to end up with a game of whack-a-mole trying to identify which Run commands need to be using this.
FYI: I think this PR is good and clear to fix the bug, and can be backported easily.
To make the Git module code clear, in the future there can be a refactor to remove both Timeout and UseContextTimeout, and make git.Run respects the context's deadline directly, then the whack-a-mole game can be avoided.
Sounds good to me. I personally think this is an important fix for 1.17.1 since it can render people unable to push or pull when it trips.
Please send backport