Skip to content

Commit

Permalink
throw error if we fail a mutation twice
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Dec 5, 2023
1 parent a541701 commit 3bb9399
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions server/src/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ export async function push(requestBody: ReadonlyJSONValue) {
for (const mutation of push.mutations) {
const result = await processMutation(push.clientGroupID, mutation, null);
if (result && 'error' in result) {
await processMutation(push.clientGroupID, mutation, result.error);
const result2 = await processMutation(
push.clientGroupID,
mutation,
result.error,
);
if (result2 && 'error' in result2) {
throw result2.error;
}
}
}

Expand All @@ -57,8 +64,8 @@ export async function push(requestBody: ReadonlyJSONValue) {
async function processMutation(
clientGroupID: string,
mutation: Mutation,
error: string | null,
): Promise<null | {error: string}> {
error: Error | null,
): Promise<null | {error: Error}> {
return await transact(async executor => {
console.log(
error === null ? 'Processing mutation' : 'Processing mutation error',
Expand Down Expand Up @@ -97,7 +104,7 @@ async function processMutation(
console.error(
`Error executing mutation: ${JSON.stringify(mutation)}: ${e}`,
);
return {error: String(e)};
return {error: e as unknown as Error};
}
}

Expand Down

0 comments on commit 3bb9399

Please sign in to comment.