Skip to content

Commit

Permalink
Merge pull request #14717 from Budibase/graceful-sqs-5xx-error-handling
Browse files Browse the repository at this point in the history
Fix SQS error handling.
  • Loading branch information
samwho authored Oct 8, 2024
2 parents ca8ed4f + a4a90d7 commit be4bc43
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/backend-core/src/db/couch/DatabaseImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,21 @@ export class DatabaseImpl implements Database {
return this.performCall(() => {
return async () => {
const response = await directCouchUrlCall(args)
const json = await response.json()
const text = await response.text()
if (response.status > 300) {
let json
try {
json = JSON.parse(text)
} catch (err) {
console.error(`SQS error: ${text}`)
throw new CouchDBError(
"error while running SQS query, please try again later",
{ name: "sqs_error", status: response.status }
)
}
throw json
}
return json as T
return JSON.parse(text) as T
}
})
}
Expand Down

0 comments on commit be4bc43

Please sign in to comment.