From 9483765a7ca101acbc5e9f228cf6d68db0e53658 Mon Sep 17 00:00:00 2001 From: Ben Merckx Date: Tue, 10 Dec 2024 10:54:53 +0100 Subject: [PATCH] Handle mutation retries based on the http status code --- src/backend/Handler.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/Handler.ts b/src/backend/Handler.ts index e475f4f5..bff6774d 100644 --- a/src/backend/Handler.ts +++ b/src/backend/Handler.ts @@ -5,6 +5,7 @@ import {CMS} from 'alinea/core/CMS' import {Connection} from 'alinea/core/Connection' import {Draft, DraftKey, formatDraftKey} from 'alinea/core/Draft' import {AnyQueryResult, Graph, GraphQuery} from 'alinea/core/Graph' +import {HttpError} from 'alinea/core/HttpError' import {EditMutation, Mutation, MutationType} from 'alinea/core/Mutation' import {PreviewUpdate} from 'alinea/core/Preview' import {getScope} from 'alinea/core/Scope' @@ -131,8 +132,8 @@ export function createHandler( await Promise.all(tasks) return {commitHash: result.commitHash} } catch (error: any) { - if ('expectedCommitHash' in error) { - if (retry) throw error + if (retry) throw error + if (error instanceof HttpError && error.code === 409) { await syncPending(ctx) return mutate(ctx, mutations, true) }