Skip to content

Commit bb632b9

Browse files
committed
throw error if we fail a mutation twice
1 parent 02dc6d8 commit bb632b9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

server/src/push.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ export async function push(requestBody: ReadonlyJSONValue) {
4545
for (const mutation of push.mutations) {
4646
const result = await processMutation(push.clientGroupID, mutation, null);
4747
if (result && 'error' in result) {
48-
await processMutation(push.clientGroupID, mutation, result.error);
48+
const result2 = await processMutation(
49+
push.clientGroupID,
50+
mutation,
51+
result.error,
52+
);
53+
if (result2 && 'error' in result2) {
54+
throw result2.error;
55+
}
4956
}
5057
}
5158

@@ -57,8 +64,8 @@ export async function push(requestBody: ReadonlyJSONValue) {
5764
async function processMutation(
5865
clientGroupID: string,
5966
mutation: Mutation,
60-
error: string | null,
61-
): Promise<null | {error: string}> {
67+
error: Error | null,
68+
): Promise<null | {error: Error}> {
6269
return await transact(async executor => {
6370
console.log(
6471
error === null ? 'Processing mutation' : 'Processing mutation error',
@@ -97,7 +104,7 @@ async function processMutation(
97104
console.error(
98105
`Error executing mutation: ${JSON.stringify(mutation)}: ${e}`,
99106
);
100-
return {error: String(e)};
107+
return {error: e as unknown as Error};
101108
}
102109
}
103110

0 commit comments

Comments
 (0)