Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/builder/app/builder/shared/sync/sync-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,18 @@ const syncServer = async function () {
if (details.authToken) {
headers.append("x-auth-token", details.authToken);
}
// revise patches are not used on the server and reduce possible patch size
const optimizedTransactions = transactions.map((transaction) => ({
...transaction,
payload: transaction.payload.map((change) => ({
namespace: change.namespace,
patches: change.patches,
})),
}));
const response = await fetch(restPatchPath(), {
method: "post",
body: JSON.stringify({
transactions,
transactions: optimizedTransactions,
buildId: details.buildId,
projectId,
// provide latest stored version to server
Expand Down
8 changes: 6 additions & 2 deletions apps/builder/app/routes/rest.patch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { applyPatches, enableMapSet, enablePatches } from "immer";
import { applyPatches, enableMapSet, enablePatches, type Patch } from "immer";
import type { ActionFunctionArgs } from "@remix-run/server-runtime";
import type { Change } from "immerhin";
import {
Breakpoints,
Breakpoint,
Expand Down Expand Up @@ -51,6 +50,11 @@ import { preventCrossOriginCookie } from "~/services/no-cross-origin-cookie";
import { checkCsrf } from "~/services/csrf-session.server";
import type { Transaction } from "~/shared/sync-client";

type Change = {
namespace: string;
patches: Array<Patch>;
};

type PatchData = {
transactions: Transaction<Change[]>[];
buildId: Build["id"];
Expand Down
Loading