From 69fed4e033c6d6f5b1d4837d8fc4b2b3dba4adbf Mon Sep 17 00:00:00 2001 From: chrisftian Date: Tue, 30 Jan 2024 16:43:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=BC=E5=AE=B9=E4=BD=8E=E7=89=88?= =?UTF-8?q?=E6=9C=AC=20nodejs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- sdk/advance.js | 2 +- sdk/base.js | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index c923053..39e161e 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/sdk/advance.js b/sdk/advance.js index d3cddfa..bc12ec6 100644 --- a/sdk/advance.js +++ b/sdk/advance.js @@ -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; diff --git a/sdk/base.js b/sdk/base.js index 2f8fdca..56c32de 100644 --- a/sdk/base.js +++ b/sdk/base.js @@ -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; @@ -4017,8 +4017,8 @@ 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; @@ -4026,8 +4026,8 @@ function submitRequest(params, callback) { } 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;