components icon indicating copy to clipboard operation
components copied to clipboard

无法使用 sls deploy --all 部署多个组件

Open ShadowWaIker opened this issue 4 years ago • 2 comments

sls deploy --all 时,如果有4到5个组件( 1个db,n个scf ),platform-client-china ( @serverless/platform-client-china ) 就开始随缘抛出错误。

Error: Internal Serverless Error - Please send this error code to support at [email protected] - 361504b0-97ea-11ea-b8d5-********* at processTencentAPIResponse (/usr/local/lib/node_modules/serverless/node_modules/@serverless/platform-client-china/src/api.js:65:11) at Object.get (/usr/local/lib/node_modules/serverless/node_modules/@serverless/platform-client-china/src/api.js:171:14) at process._tickCallback (internal/process/next_tick.js:68:7)

这个出错的概率跟组件数量正相关,我这边测试的情况是组件数量达到7个之后,100% 报错。

Framework Core: 1.70.1、Plugin: 3.6.11 的时候,这里抛出错误之后会一直 deploy 个没完,但是最终还是可以把所有组件都部署上去的。

今天升级到Framework Core: 1.71.1、Plugin: 3.6.12 之后,这里抛出错误就会结束 deploy 进程。在 dashboard 可以看到部分 scf 组件出现 status error, 错误 message 是 : There's a problem with your files and they could not be loaded by this Component. Original error: Response code 404 (Not Found)

修改 /usr/local/lib/node_modules/serverless/node_modules/@serverless/platform-client-china/src/api.js 中的 processTencentAPIResponse 方法, 增加 1s 的延迟后, 可以临时解决这个报错。

var sleep = function(time) { var startTime = new Date().getTime() + parseInt(time, 10); while(new Date().getTime() < startTime) {} }; function processTencentAPIResponse(response) { sleep(1000); // 延时函数,单位ms if (response && response.Body) { let payload; let payloadBody; try { payload = JSON.parse(response.Body); payloadBody = JSON.parse(payload.body); } catch (e) { console.log('bad response from tencent', response); const err = new Error('bad response from tencent'); err.resBody = response.Body; throw err; } if (payload.statusCode === 200) { return payloadBody; } console.log(response) console.log(payloadBody) throw new Error(payloadBody.message); } throw new Error('access Tencent API failed, get empty response'); }

但是如果此时继续增加组件,报错仍旧会出现,此时只能继续增加延时来解决这个问题。

目前,部署1个db组件, 10个scf组件时,需要在 processTencentAPIResponse 中 sleep 至少 5s 才能解决 platform-client-china 抛出 Internal Serverless Error 的问题。但是此时又会随缘出现 RequestLimitExceeded 报错:

Error: {"Error":{"Code":"RequestLimitExceeded","Message":"Your current request times equals to 21 in a second, which exceeds the frequency limit 20 for a second. Please reduce the frequency of calls."},"RequestId":"592b3ce1-e56a-4fa6-ab71-*******"} at Scf.getFunction (/var/user/node_modules/tencent-component-toolkit/src/baas/scf/index.js:155:15) at process._tickCallback (internal/process/next_tick.js:68:7) 182s › base-on-serverless › {"Error":{"Code":"RequestLimitExceeded","Message":"Your current request times equals to 21 in a second, which exceeds the frequency limit 20 for a second. Please reduce the frequency of calls."},"RequestId":"592b3ce1-e56a-4fa6-ab71-********"}

tencent-component-toolkit 这个组件似乎在云端,本地找不到 /var/user/node_modules/tencent-component-toolkit/src/baas/scf/index.js 这个文件。此时,通过增加 sleep 的方式来解决这个报错的方法都行不通了。

个人猜测问题的原因主要是云API调用频率限制。

ShadowWaIker avatar May 17 '20 03:05 ShadowWaIker

@tinafangkunding could you help to check the rate limit issue?

hkbarton avatar May 19 '20 07:05 hkbarton

这个问题可能需要提工单增加一些接口调用频率限制才能解决。我和@jorge 看看有没有其他好的方式解决

tinafangkunding avatar May 23 '20 14:05 tinafangkunding