mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-12 00:39:03 +08:00
fix(v1/checkCredits): snap crawl limit to remaining credits if over without erroring out (#1350)
This commit is contained in:
parent
87ad53e727
commit
670ca84ae9
@ -52,7 +52,18 @@ function checkCreditsMiddleware(
|
||||
if (chunk) {
|
||||
req.acuc = chunk;
|
||||
}
|
||||
req.account = { remainingCredits };
|
||||
if (!success) {
|
||||
if (!minimum && req.body && (req.body as any).limit !== undefined && remainingCredits > 0) {
|
||||
logger.warn("Adjusting limit to remaining credits", {
|
||||
teamId: req.auth.team_id,
|
||||
remainingCredits,
|
||||
request: req.body,
|
||||
});
|
||||
(req.body as any).limit = remainingCredits;
|
||||
return next();
|
||||
}
|
||||
|
||||
const currencyName = req.acuc.is_extract ? "tokens" : "credits"
|
||||
logger.error(
|
||||
`Insufficient ${currencyName}: ${JSON.stringify({ team_id: req.auth.team_id, minimum, remainingCredits })}`,
|
||||
@ -72,7 +83,6 @@ function checkCreditsMiddleware(
|
||||
});
|
||||
}
|
||||
}
|
||||
req.account = { remainingCredits };
|
||||
next();
|
||||
})().catch((err) => next(err));
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user