fix: reject oversized checkout diffs (#2488)

* fix: reject oversized checkout diffs

* fix(diff): keep large previews from disconnecting clients

The physical socket limit is an OOM backstop, not a frame-size contract. Bound structured diff construction incrementally and report oversized previews without closing the client's socket.

* fix(app): preserve oversized diff state

* fix(diff): stay within relay frame limit

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
nikuscs
2026-07-30 00:48:05 +08:00
committed by GitHub
co-authored by Mohamed Boudra
parent 16bbead5a4
commit 9e5accee3c
24 changed files with 321 additions and 81 deletions
+11 -2
View File
@@ -204,25 +204,34 @@ describe("server data push router", () => {
fake.emit({
type: "subscribe_checkout_diff_response",
payload: { subscriptionId, cwd, files: [], error: null, requestId: "diff-1" },
payload: {
subscriptionId,
cwd,
files: [],
error: null,
diffTooLarge: true,
requestId: "diff-1",
},
});
expect(queryClient.getQueryData(queryKey)).toEqual({
cwd,
files: [],
error: null,
diffTooLarge: true,
requestId: "diff-1",
});
fake.emit({
type: "checkout_diff_update",
payload: { subscriptionId, cwd, files: [], error: null },
payload: { subscriptionId, cwd, files: [], error: null, diffTooLarge: true },
});
expect(queryClient.getQueryData(queryKey)).toEqual({
cwd,
files: [],
error: null,
diffTooLarge: true,
requestId: `subscription:${subscriptionId}`,
});
+6
View File
@@ -420,6 +420,9 @@ function applyCheckoutDiffUpdate(input: {
cwd: input.message.payload.cwd,
files: orderCheckoutDiffFiles(input.message.payload.files),
error: input.message.payload.error,
...(input.message.payload.diffTooLarge !== undefined
? { diffTooLarge: input.message.payload.diffTooLarge }
: {}),
requestId: `subscription:${input.message.payload.subscriptionId}`,
},
});
@@ -440,6 +443,9 @@ function applyCheckoutDiffSubscribeResponse(input: {
cwd: input.message.payload.cwd,
files: orderCheckoutDiffFiles(input.message.payload.files),
error: input.message.payload.error,
...(input.message.payload.diffTooLarge !== undefined
? { diffTooLarge: input.message.payload.diffTooLarge }
: {}),
requestId: input.message.payload.requestId,
},
});