mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
feat: add http node timeout (#2465)
* fix $ in replacement string misinterpreted as regex special character * add http timeout * delete console log
This commit is contained in:
@@ -57,6 +57,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
system_httpHeader: httpHeader,
|
||||
system_httpParams: httpParams = [],
|
||||
system_httpJsonBody: httpJsonBody,
|
||||
system_httpTimeout: httpTimeout,
|
||||
[NodeInputKeyEnum.addInputParam]: dynamicInput,
|
||||
...body
|
||||
}
|
||||
@@ -143,7 +144,8 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
|
||||
url: httpReqUrl,
|
||||
headers,
|
||||
body: requestBody,
|
||||
params
|
||||
params,
|
||||
timeout: httpTimeout
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -199,13 +201,15 @@ async function fetchData({
|
||||
url,
|
||||
headers,
|
||||
body,
|
||||
params
|
||||
params,
|
||||
timeout
|
||||
}: {
|
||||
method: string;
|
||||
url: string;
|
||||
headers: Record<string, any>;
|
||||
body: Record<string, any> | string;
|
||||
params: Record<string, any>;
|
||||
timeout: number;
|
||||
}) {
|
||||
const { data: response } = await axios({
|
||||
method,
|
||||
@@ -215,7 +219,7 @@ async function fetchData({
|
||||
'Content-Type': 'application/json',
|
||||
...headers
|
||||
},
|
||||
timeout: 120000,
|
||||
timeout: timeout * 1000,
|
||||
params: params,
|
||||
data: ['POST', 'PUT', 'PATCH'].includes(method) ? body : undefined
|
||||
});
|
||||
@@ -308,7 +312,7 @@ function replaceVariable(text: string, obj: Record<string, any>) {
|
||||
replacement.startsWith('"') && replacement.endsWith('"')
|
||||
? replacement.slice(1, -1)
|
||||
: replacement;
|
||||
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), unquotedReplacement);
|
||||
text = text.replace(new RegExp(`{{(${key})}}`, 'g'), () => unquotedReplacement);
|
||||
}
|
||||
}
|
||||
return text || '';
|
||||
|
Reference in New Issue
Block a user