mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 07:29:04 +08:00
feat(sdk): enforce timeout on client-side if set (#1204)
This commit is contained in:
parent
dc1501527a
commit
c75522f535
@ -535,7 +535,7 @@ export default class FirecrawlApp {
|
||||
const response: AxiosResponse = await axios.post(
|
||||
this.apiUrl + `/v1/scrape`,
|
||||
jsonData,
|
||||
{ headers }
|
||||
{ headers, timeout: params?.timeout !== undefined ? (params.timeout + 5000) : undefined },
|
||||
);
|
||||
if (response.status === 200) {
|
||||
const responseData = response.data;
|
||||
@ -1262,7 +1262,7 @@ export default class FirecrawlApp {
|
||||
data: any,
|
||||
headers: AxiosRequestHeaders
|
||||
): Promise<AxiosResponse> {
|
||||
return axios.post(url, data, { headers });
|
||||
return axios.post(url, data, { headers, timeout: (data?.timeout ? (data.timeout + 5000) : undefined) });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,6 +145,7 @@ class FirecrawlApp:
|
||||
f'{self.api_url}{endpoint}',
|
||||
headers=headers,
|
||||
json=scrape_params,
|
||||
timeout=(scrape_params["timeout"] + 5000 if "timeout" in scrape_params else None),
|
||||
)
|
||||
if response.status_code == 200:
|
||||
try:
|
||||
@ -925,7 +926,7 @@ class FirecrawlApp:
|
||||
requests.RequestException: If the request fails after the specified retries.
|
||||
"""
|
||||
for attempt in range(retries):
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
response = requests.post(url, headers=headers, json=data, timeout=((data["timeout"] + 5000) if "timeout" in data else None))
|
||||
if response.status_code == 502:
|
||||
time.sleep(backoff_factor * (2 ** attempt))
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user