Buffer request body to fix large push deadlock
This commit is contained in:
parent
360f4cedcf
commit
18c585e6a6
|
|
@ -252,7 +252,7 @@ async function getDefaultBranch(bare: string): Promise<string> {
|
||||||
async function gitRpc(
|
async function gitRpc(
|
||||||
repo: string,
|
repo: string,
|
||||||
service: string,
|
service: string,
|
||||||
body: ReadableStream<Uint8Array> | null,
|
body: Uint8Array | ReadableStream<Uint8Array> | null,
|
||||||
): Promise<Response> {
|
): Promise<Response> {
|
||||||
const bare = repoPath(repo)
|
const bare = repoPath(repo)
|
||||||
|
|
||||||
|
|
@ -594,7 +594,12 @@ app.on('POST', ['/:repo{.+\\.git}/git-receive-pack', '/:repo/git-receive-pack'],
|
||||||
|
|
||||||
await ensureBareRepo(repoParam)
|
await ensureBareRepo(repoParam)
|
||||||
|
|
||||||
const response = await gitRpc(repoParam, 'git-receive-pack', c.req.raw.body)
|
// Buffer the request body before passing to git-receive-pack. Piping a live
|
||||||
|
// HTTP ReadableStream directly to subprocess stdin deadlocks on large pushes:
|
||||||
|
// the pipe buffer fills, stalling the stream reader, while git-receive-pack
|
||||||
|
// can't finish reading stdin to produce stdout — both sides block.
|
||||||
|
const body = new Uint8Array(await c.req.raw.arrayBuffer())
|
||||||
|
const response = await gitRpc(repoParam, 'git-receive-pack', body)
|
||||||
// Buffer the full response so we can inject sideband error messages before the
|
// Buffer the full response so we can inject sideband error messages before the
|
||||||
// final flush-pkt on deploy failure. The receive-pack response is just ref status
|
// final flush-pkt on deploy failure. The receive-pack response is just ref status
|
||||||
// lines (not pack data), so the buffer is small regardless of push size.
|
// lines (not pack data), so the buffer is small regardless of push size.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user