mirror of
https://github.com/graphql-hive/console
synced 2026-05-22 16:48:56 +00:00
More insights from S3 client when fetching from S3 and R2 (#6513)
This commit is contained in:
parent
5c3bbd39b8
commit
b40cadf8b2
1 changed files with 26 additions and 7 deletions
|
|
@ -148,9 +148,10 @@ export class ArtifactStorageReader {
|
|||
const abortOtherRequest = (ctrl: AbortController, source: string) => {
|
||||
return (res: Response) => {
|
||||
this.breadcrumb(`Successful fetch from "${source}", aborting other request`);
|
||||
// abort other pending request
|
||||
const error = new PendingRequestAbortedError();
|
||||
ctrl.abort(error);
|
||||
if (!ctrl.signal.aborted) {
|
||||
// abort other pending request
|
||||
ctrl.abort(new PendingRequestAbortedError());
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
|
@ -183,7 +184,11 @@ export class ArtifactStorageReader {
|
|||
});
|
||||
},
|
||||
})
|
||||
.then(abortOtherRequest(mirrorController, 'primary')),
|
||||
.then(abortOtherRequest(mirrorController, 'primary'))
|
||||
.catch(error => {
|
||||
this.breadcrumb(`Failed to fetch from primary (error=${stringifyError(error)})`);
|
||||
return Promise.reject(error);
|
||||
}),
|
||||
this.s3Mirror.client
|
||||
.fetch(mirrorObjectEndpoint, {
|
||||
method: args.method,
|
||||
|
|
@ -202,8 +207,22 @@ export class ArtifactStorageReader {
|
|||
});
|
||||
},
|
||||
})
|
||||
.then(abortOtherRequest(primaryController, 'mirror')),
|
||||
]);
|
||||
.then(abortOtherRequest(primaryController, 'mirror'))
|
||||
.catch(error => {
|
||||
this.breadcrumb(`Failed to fetch from mirror (error=${stringifyError(error)})`);
|
||||
return Promise.reject(error);
|
||||
}),
|
||||
]).catch(error => {
|
||||
this.breadcrumb(`Both requests failed: ${stringifyError(error)}`);
|
||||
|
||||
if (error instanceof AggregateError && error.errors) {
|
||||
for (let i = 0; i < error.errors.length; i++) {
|
||||
this.breadcrumb(`Request ${i} failed: ${stringifyError(error.errors[i])}`);
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -446,7 +465,7 @@ export class ArtifactStorageReader {
|
|||
|
||||
this.analytics?.track(
|
||||
{
|
||||
type: args.isMirror ? 'r2' : 's3',
|
||||
type: args.isMirror ? 's3' : 'r2',
|
||||
statusCodeOrErrCode:
|
||||
args.result.type === 'error'
|
||||
? String(args.result.error.name ?? 'unknown')
|
||||
|
|
|
|||
Loading…
Reference in a new issue