@xuda.io/xuda-worker-bundle-min 1.3.507 → 1.3.509
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/index.js +26 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1064,6 +1064,23 @@ func.common.perform_rpi_request = async function (
|
|
|
1064
1064
|
data
|
|
1065
1065
|
) {
|
|
1066
1066
|
const http = async function () {
|
|
1067
|
+
const fetchWithTimeout = (url, options = {}, timeout = 600000) => {
|
|
1068
|
+
// 100 seconds
|
|
1069
|
+
const controller = new AbortController();
|
|
1070
|
+
const { signal } = controller;
|
|
1071
|
+
|
|
1072
|
+
const timeoutPromise = new Promise((_, reject) =>
|
|
1073
|
+
setTimeout(() => {
|
|
1074
|
+
controller.abort();
|
|
1075
|
+
reject(new Error("Request timed out"));
|
|
1076
|
+
}, timeout)
|
|
1077
|
+
);
|
|
1078
|
+
|
|
1079
|
+
const fetchPromise = fetch(url, { ...options, signal });
|
|
1080
|
+
|
|
1081
|
+
return Promise.race([fetchPromise, timeoutPromise]);
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1067
1084
|
var url = func.common.get_url(SESSION_ID, "rpi", "");
|
|
1068
1085
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
1069
1086
|
const app_id = _session.APP_ID;
|
|
@@ -1078,7 +1095,7 @@ func.common.perform_rpi_request = async function (
|
|
|
1078
1095
|
url += serviceP;
|
|
1079
1096
|
|
|
1080
1097
|
try {
|
|
1081
|
-
const response = await
|
|
1098
|
+
const response = await fetchWithTimeout(url, {
|
|
1082
1099
|
method: opt.type ? opt.type : "POST",
|
|
1083
1100
|
headers: {
|
|
1084
1101
|
Accept: "application/json",
|
|
@@ -1086,6 +1103,14 @@ func.common.perform_rpi_request = async function (
|
|
|
1086
1103
|
},
|
|
1087
1104
|
body: JSON.stringify(data),
|
|
1088
1105
|
});
|
|
1106
|
+
// const response = await fetch(url, {
|
|
1107
|
+
// method: opt.type ? opt.type : "POST",
|
|
1108
|
+
// headers: {
|
|
1109
|
+
// Accept: "application/json",
|
|
1110
|
+
// "Content-Type": "application/json",
|
|
1111
|
+
// },
|
|
1112
|
+
// body: JSON.stringify(data),
|
|
1113
|
+
// });
|
|
1089
1114
|
if (!response.ok) throw "";
|
|
1090
1115
|
const json = await response.json();
|
|
1091
1116
|
return json;
|