File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
components/server/src/authorization Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ export class SpiceDBAuthorizer {
57
57
const timer = spicedbClientLatency . startTimer ( ) ;
58
58
let error : Error | undefined ;
59
59
try {
60
- const response = await this . call ( "[spicedb] Failed to perform authorization check." , ( client ) =>
60
+ const response = await this . call ( "[spicedb] Error performing authorization check." , ( client ) =>
61
61
client . checkPermission ( req , this . callOptions ) ,
62
62
) ;
63
63
const permitted = response . permissionship === v1 . CheckPermissionResponse_Permissionship . HAS_PERMISSION ;
@@ -185,14 +185,15 @@ export class SpiceDBAuthorizer {
185
185
private async call < T > ( description : string , code : ( client : v1 . ZedPromiseClientInterface ) => Promise < T > ) : Promise < T > {
186
186
const MAX_ATTEMPTS = 3 ;
187
187
let attempt = 0 ;
188
- while ( attempt ++ < 3 ) {
188
+ while ( attempt ++ < MAX_ATTEMPTS ) {
189
189
try {
190
190
const checkClient = attempt > 1 ; // the last client error'd out, so check if we should get a new one
191
191
const client = this . clientProvider . getClient ( checkClient ) ;
192
- return code ( client ) ;
192
+ return await code ( client ) ;
193
193
} catch ( err ) {
194
194
// Check: Is this a "no connection to upstream" error? If yes, retry here, to work around grpc/grpc-js bugs introducing high latency for re-tries
195
195
if (
196
+ isGrpcError ( err ) &&
196
197
( err . code === grpc . status . DEADLINE_EXCEEDED || err . code === grpc . status . UNAVAILABLE ) &&
197
198
attempt < MAX_ATTEMPTS
198
199
) {
You can’t perform that action at this time.
0 commit comments