Skip to content

Commit d17c7ee

Browse files
committed
Handle BrokenPipe errors gracefully during git push
When git finishes receiving all the data it needs during a push operation, it may close the pipe before git-remote-sqlite finishes writing its final response. This is expected behavior - the push has succeeded from git's perspective, and we should not treat this as a fatal error. This was causing CI failures during the repo-db build step when running `git push --mirror`, where git would close the connection after receiving all objects but before reading the final "ok" response. ## Test plan Ran `zig build test` and `zig build repo-db` locally to verify the fix. The repo-db step now completes successfully without the BrokenPipe error.
1 parent 6fb366f commit d17c7ee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/transport.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,13 @@ pub const ProtocolHandler = struct {
127127
else => return self.fatalError("Command failed: {}\n", .{err}),
128128
};
129129

130-
response.format("", .{}, self.out) catch |err| {
131-
return self.fatalError("Failed to write response: {}\n", .{err});
130+
response.format("", .{}, self.out) catch |err| switch (err) {
131+
error.BrokenPipe => {
132+
// Git may close the pipe after receiving all data it needs.
133+
// This is expected behavior and not an error.
134+
break;
135+
},
136+
else => return self.fatalError("Failed to write response: {}\n", .{err}),
132137
};
133138
}
134139
}

0 commit comments

Comments
 (0)