Skip to content

Commit

Permalink
fix: 兼容低版本 nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
livehigh committed Jan 30, 2024
1 parent 3c53f3e commit 69fed4e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cos-nodejs-sdk-v5",
"version": "2.13.0",
"version": "2.13.1",
"description": "cos nodejs sdk v5",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion sdk/advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ function uploadSliceItem(params, callback) {
function (err, data) {
if (!self._isRunningTask(TaskId)) return;
if (err) {
switchHost = err?.switchHost;
switchHost = err.switchHost || false;
}
if (err) return tryCallback(err);
PartItem.Uploaded = true;
Expand Down
10 changes: 5 additions & 5 deletions sdk/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3923,7 +3923,7 @@ function allowRetry(err) {
networkError = true;
} else {
const statusCode = Math.floor(err.statusCode / 100);
const requestId = err?.headers && err?.headers['x-cos-request-id'];
const requestId = err.headers ? err.headers['x-cos-request-id'] : '';
if ([3, 4, 5].includes(statusCode) && !requestId) {
canRetry = self.options.AutoSwitchHost;
networkError = true;
Expand Down Expand Up @@ -4017,17 +4017,17 @@ function submitRequest(params, callback) {
}
// 进入重试逻辑时 需判断是否需要切换cos备用域名
const switchHost = canSwitchHost.call(self, {
requestUrl: err?.url || '',
clientCalcSign: AuthData?.SignFrom === 'client',
requestUrl: err.url || '',
clientCalcSign: AuthData.SignFrom === 'client',
networkError,
});
params.SwitchHost = switchHost;
next(tryTimes + 1);
} else {
if (err && params.Action === 'name/cos:UploadPart') {
const switchHost = canSwitchHost.call(self, {
requestUrl: err?.url || '',
clientCalcSign: AuthData?.SignFrom === 'client',
requestUrl: err.url || '',
clientCalcSign: AuthData.SignFrom === 'client',
networkError,
});
err.switchHost = switchHost;
Expand Down

0 comments on commit 69fed4e

Please sign in to comment.