Skip to content

Commit

Permalink
feat: ignore error when s3 qeury domains by server may not support
Browse files Browse the repository at this point in the history
  • Loading branch information
lihsai0 committed May 31, 2024
1 parent 7954516 commit bdd9945
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { HttpClient, RequestStats } from './http-client';
import { ServiceName } from './kodo-http-client';
import { RegionRequestOptions } from './region';
import { generateReqId } from './req_id';
import {HttpClientResponse} from "urllib";

export const USER_AGENT = `Qiniu-Kodo-S3-Adapter-NodeJS-SDK/${pkg.version} (${os.type()}; ${os.platform()}; ${os.arch()}; )/s3`;

Expand Down Expand Up @@ -425,18 +426,26 @@ export class S3 extends Kodo {
bucket,
type: 'all',
};
const domainResponse = await this.call({
method: 'GET',
serviceName: ServiceName.Uc,
path: 'domain',
query: domainQuery,
dataType: 'json',
s3RegionId,

// for uplog
apiName: 'queryDomain',
targetBucket: bucket,
});

let domainResponse: HttpClientResponse<any>;
try {
domainResponse = await this.call({
method: 'GET',
serviceName: ServiceName.Uc,
path: 'domain',
query: domainQuery,
dataType: 'json',
s3RegionId,

// for uplog
apiName: 'queryDomain',
targetBucket: bucket,
});
} catch (err) {
// some server haven't this API. It will cause error.
// ignore it with an empty domain list.
return [];
}

if (!Array.isArray(domainResponse.data)) {
return [];
Expand Down

0 comments on commit bdd9945

Please sign in to comment.