@iflyrpa/actions 4.0.0-beta.4 → 4.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +39 -14
- package/dist/bundle.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -8734,9 +8734,9 @@ var __webpack_exports__ = {};
|
|
|
8734
8734
|
origin: ()=>utils_origin
|
|
8735
8735
|
});
|
|
8736
8736
|
var package_namespaceObject = {
|
|
8737
|
-
i8: "0.1.
|
|
8737
|
+
i8: "0.1.1"
|
|
8738
8738
|
};
|
|
8739
|
-
var package_namespaceObject_0 = JSON.parse('{"i8":"
|
|
8739
|
+
var package_namespaceObject_0 = JSON.parse('{"i8":"4.0.0-beta.5"}');
|
|
8740
8740
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
8741
8741
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
8742
8742
|
const external_node_http_namespaceObject = require("node:http");
|
|
@@ -8777,6 +8777,7 @@ var __webpack_exports__ = {};
|
|
|
8777
8777
|
}
|
|
8778
8778
|
});
|
|
8779
8779
|
}
|
|
8780
|
+
const DOWNLOAD_BASE_TIMEOUT = 60000;
|
|
8780
8781
|
async function downloadImage(url, savePath, retries = 3) {
|
|
8781
8782
|
const RETRYABLE_CODES = new Set([
|
|
8782
8783
|
"ECONNRESET",
|
|
@@ -8784,20 +8785,25 @@ var __webpack_exports__ = {};
|
|
|
8784
8785
|
"EAI_AGAIN",
|
|
8785
8786
|
"ENOTFOUND"
|
|
8786
8787
|
]);
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8788
|
+
const maxAttempts = retries;
|
|
8789
|
+
let lastErr;
|
|
8790
|
+
for(let attempt = 1; attempt <= maxAttempts; attempt++){
|
|
8791
|
+
const timeout = attempt * DOWNLOAD_BASE_TIMEOUT;
|
|
8792
|
+
try {
|
|
8793
|
+
return await downloadImageOnce(url, savePath, timeout);
|
|
8794
|
+
} catch (err) {
|
|
8795
|
+
var _err_extra;
|
|
8796
|
+
lastErr = err;
|
|
8797
|
+
const errCode = (null == err ? void 0 : err.code) ?? (null == err ? void 0 : null === (_err_extra = err.extra) || void 0 === _err_extra ? void 0 : _err_extra.code);
|
|
8798
|
+
const retryable = RETRYABLE_CODES.has(errCode) || (null == err ? void 0 : err.code) === 500;
|
|
8799
|
+
if (attempt >= maxAttempts || !retryable) throw err;
|
|
8800
|
+
console.warn(`downloadImage 失败,已尝试 ${attempt}/${maxAttempts} 次,下次超时 ${(attempt + 1) * DOWNLOAD_BASE_TIMEOUT / 1000}s,url: ${url},原因:`, (null == err ? void 0 : err.message) ?? err);
|
|
8794
8801
|
await new Promise((r)=>setTimeout(r, 1000));
|
|
8795
|
-
return downloadImage(url, savePath, retries - 1);
|
|
8796
8802
|
}
|
|
8797
|
-
throw err;
|
|
8798
8803
|
}
|
|
8804
|
+
throw lastErr;
|
|
8799
8805
|
}
|
|
8800
|
-
async function downloadImageOnce(url, savePath) {
|
|
8806
|
+
async function downloadImageOnce(url, savePath, timeout = DOWNLOAD_BASE_TIMEOUT) {
|
|
8801
8807
|
await ensureFile(savePath);
|
|
8802
8808
|
return new Promise((resolve, reject)=>{
|
|
8803
8809
|
const handleResponse = (response)=>{
|
|
@@ -8879,11 +8885,24 @@ var __webpack_exports__ = {};
|
|
|
8879
8885
|
};
|
|
8880
8886
|
const requestFn = url.startsWith("http://") ? external_node_http_namespaceObject.get : external_node_https_namespaceObject.get;
|
|
8881
8887
|
const req = requestFn(url, handleResponse);
|
|
8882
|
-
|
|
8888
|
+
let remoteAddress = "";
|
|
8889
|
+
req.on("socket", (socket)=>{
|
|
8890
|
+
socket.on("connect", ()=>{
|
|
8891
|
+
remoteAddress = `${socket.remoteAddress ?? ""}:${socket.remotePort ?? ""}`;
|
|
8892
|
+
});
|
|
8893
|
+
if (socket.remoteAddress) remoteAddress = `${socket.remoteAddress}:${socket.remotePort ?? ""}`;
|
|
8894
|
+
});
|
|
8895
|
+
req.setTimeout(timeout, ()=>{
|
|
8883
8896
|
req.destroy();
|
|
8897
|
+
const remoteInfo = remoteAddress || "未建立连接";
|
|
8898
|
+
console.warn(`图片下载超时 (${timeout / 1000}s),远端IP: ${remoteInfo},Url:${url}`);
|
|
8884
8899
|
reject({
|
|
8885
8900
|
code: 500,
|
|
8886
|
-
message: `图片下载超时 (${url}
|
|
8901
|
+
message: `图片下载超时 (${timeout / 1000}s) Url:${url},请检查网络连接或稍后重试! 远端ip: ${remoteInfo}`,
|
|
8902
|
+
extra: {
|
|
8903
|
+
url,
|
|
8904
|
+
remoteAddress: remoteInfo
|
|
8905
|
+
}
|
|
8887
8906
|
});
|
|
8888
8907
|
});
|
|
8889
8908
|
req.on("error", handleError);
|
|
@@ -34811,10 +34830,13 @@ var __webpack_exports__ = {};
|
|
|
34811
34830
|
].filter(Boolean).join(" ");
|
|
34812
34831
|
const message = `图文发布失败,原因:${details}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
34813
34832
|
task.logger.warn(`TaskId:${task.taskId},检测到需要验证,准备返回验证信息`);
|
|
34833
|
+
let decisionObj = {};
|
|
34834
|
+
if (decision) decisionObj = decision;
|
|
34814
34835
|
const mockData = {
|
|
34815
34836
|
state: types_TaskState.FAILED,
|
|
34816
34837
|
error: message,
|
|
34817
34838
|
result: {
|
|
34839
|
+
...decisionObj,
|
|
34818
34840
|
data: decision,
|
|
34819
34841
|
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
34820
34842
|
}
|
|
@@ -34844,10 +34866,13 @@ var __webpack_exports__ = {};
|
|
|
34844
34866
|
const message = `图文发布${isSuccess ? "成功" : `失败,原因:${publishResult.status_msg} ${decision?.verify_title} ${decision?.verify_desc}`}${task.debug ? ` ${http.proxyInfo}` : ""}`;
|
|
34845
34867
|
const data = isSuccess ? publishResult.item_id || "" : "";
|
|
34846
34868
|
if (!isSuccess) {
|
|
34869
|
+
let decisionObj = {};
|
|
34870
|
+
if (decision) decisionObj = decision;
|
|
34847
34871
|
await updateTaskState?.({
|
|
34848
34872
|
state: types_TaskState.FAILED,
|
|
34849
34873
|
error: message,
|
|
34850
34874
|
result: {
|
|
34875
|
+
...decisionObj,
|
|
34851
34876
|
data: decision,
|
|
34852
34877
|
uploadedImgList: JSON.stringify(publishData.item.common.images)
|
|
34853
34878
|
}
|