From 27578db4b7e0298cd11aa937f7b795252bf8e918 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Mon, 7 Oct 2024 09:48:33 +0100 Subject: [PATCH] Fix SQS error handling. --- packages/backend-core/src/db/couch/DatabaseImpl.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/backend-core/src/db/couch/DatabaseImpl.ts b/packages/backend-core/src/db/couch/DatabaseImpl.ts index 274c1b9e93..2ca52a2dce 100644 --- a/packages/backend-core/src/db/couch/DatabaseImpl.ts +++ b/packages/backend-core/src/db/couch/DatabaseImpl.ts @@ -371,11 +371,15 @@ export class DatabaseImpl implements Database { return this.performCall(() => { return async () => { const response = await directCouchUrlCall(args) - const json = await response.json() - if (response.status > 300) { - throw json + if (response.status >= 300) { + const text = await response.text() + console.error(`SQS error: ${text}`) + throw new CouchDBError( + "error while running SQS query, please try again later", + { name: "sqs_error", status: response.status } + ) } - return json as T + return (await response.json()) as T } }) }