Skip to content

Commit 69fed4e

Browse files
committed
fix: 兼容低版本 nodejs
1 parent 3c53f3e commit 69fed4e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cos-nodejs-sdk-v5",
3-
"version": "2.13.0",
3+
"version": "2.13.1",
44
"description": "cos nodejs sdk v5",
55
"main": "index.js",
66
"types": "index.d.ts",

sdk/advance.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ function uploadSliceItem(params, callback) {
674674
function (err, data) {
675675
if (!self._isRunningTask(TaskId)) return;
676676
if (err) {
677-
switchHost = err?.switchHost;
677+
switchHost = err.switchHost || false;
678678
}
679679
if (err) return tryCallback(err);
680680
PartItem.Uploaded = true;

sdk/base.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3923,7 +3923,7 @@ function allowRetry(err) {
39233923
networkError = true;
39243924
} else {
39253925
const statusCode = Math.floor(err.statusCode / 100);
3926-
const requestId = err?.headers && err?.headers['x-cos-request-id'];
3926+
const requestId = err.headers ? err.headers['x-cos-request-id'] : '';
39273927
if ([3, 4, 5].includes(statusCode) && !requestId) {
39283928
canRetry = self.options.AutoSwitchHost;
39293929
networkError = true;
@@ -4017,17 +4017,17 @@ function submitRequest(params, callback) {
40174017
}
40184018
// 进入重试逻辑时 需判断是否需要切换cos备用域名
40194019
const switchHost = canSwitchHost.call(self, {
4020-
requestUrl: err?.url || '',
4021-
clientCalcSign: AuthData?.SignFrom === 'client',
4020+
requestUrl: err.url || '',
4021+
clientCalcSign: AuthData.SignFrom === 'client',
40224022
networkError,
40234023
});
40244024
params.SwitchHost = switchHost;
40254025
next(tryTimes + 1);
40264026
} else {
40274027
if (err && params.Action === 'name/cos:UploadPart') {
40284028
const switchHost = canSwitchHost.call(self, {
4029-
requestUrl: err?.url || '',
4030-
clientCalcSign: AuthData?.SignFrom === 'client',
4029+
requestUrl: err.url || '',
4030+
clientCalcSign: AuthData.SignFrom === 'client',
40314031
networkError,
40324032
});
40334033
err.switchHost = switchHost;

0 commit comments

Comments
 (0)