Skip to content

Commit f9f0b4b

Browse files
authored
Update http468.ts (#903)
修复HTTP模块,http请求错误的stack堆栈信息长度冗余导致超过MongoDB数据库限制从而导致聊天对话插入数据库失败,修复方法为修改为如果http请求错误只返回几项重要信息而不是整个堆栈数据
1 parent 064c64e commit f9f0b4b

File tree

1 file changed

+20
-1
lines changed
  • projects/app/src/service/moduleDispatch/tools

1 file changed

+20
-1
lines changed

projects/app/src/service/moduleDispatch/tools/http468.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,15 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
130130
...results
131131
};
132132
} catch (error) {
133+
const err = httpRequestErrorResponseData(error)
133134
return {
134135
[ModuleOutputKeyEnum.failed]: true,
135136
[ModuleOutputKeyEnum.responseData]: {
136137
totalPoints: 0,
137138
params: Object.keys(params).length > 0 ? params : undefined,
138139
body: Object.keys(requestBody).length > 0 ? requestBody : undefined,
139140
headers: Object.keys(headers).length > 0 ? headers : undefined,
140-
httpResult: { error }
141+
httpResult: { error: err }
141142
}
142143
};
143144
}
@@ -279,3 +280,21 @@ function removeUndefinedSign(obj: Record<string, any>) {
279280
}
280281
return obj;
281282
}
283+
function httpRequestErrorResponseData(error: any) {
284+
try {
285+
return {
286+
message: error?.message || undefined,
287+
name: error?.name || undefined,
288+
method: error?.config?.method || undefined,
289+
baseURL: error?.config?.baseURL || undefined,
290+
url: error?.config?.url || undefined,
291+
code: error?.code || undefined,
292+
status: error?.status || undefined
293+
}
294+
} catch (error) {
295+
return {
296+
message: 'Request Failed',
297+
name: "AxiosError",
298+
};
299+
}
300+
}

0 commit comments

Comments
 (0)