Skip to content

Commit

Permalink
Increase database retries
Browse files Browse the repository at this point in the history
  • Loading branch information
hbriese committed Oct 19, 2023
1 parent eaeb959 commit 7a9fa5a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions api/src/features/database/database.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export class DatabaseService implements OnModuleInit {
readonly DANGEROUS_superuserClient: Client;

constructor() {
this.__client = createClient().withConfig({
allow_user_specified_id: true /* Required for account insertion */,
});
this.__client = createClient()
.withConfig({
allow_user_specified_id: true /* Required for account insertion */,
})
.withRetryOptions({ attempts: 5 });
this.DANGEROUS_superuserClient = this.__client.withConfig({ apply_access_policies: false });
}

Expand All @@ -33,13 +35,10 @@ export class DatabaseService implements OnModuleInit {
}

get client() {
const transaction = this.context.getStore()?.transaction;
if (transaction) return transaction;

return this._client;
return this.context.getStore()?.transaction ?? this._client;
}

private get _client() {
protected get _client() {
const ctx = getRequestContext()?.user;
if (!ctx) return this.DANGEROUS_superuserClient;

Expand Down

0 comments on commit 7a9fa5a

Please sign in to comment.