timeout if job takes more than 10 minutes

This commit is contained in:
Hongbo Wu
2024-04-22 22:37:33 +08:00
parent a77ade0890
commit de258ae0bf
3 changed files with 103 additions and 86 deletions

View File

@ -316,6 +316,12 @@ export const wait = (ms: number): Promise<void> => {
})
}
export const timeout = (ms: number): Promise<void> => {
return new Promise((_resolve, reject) => {
setTimeout(() => reject(new Error('timeout')), ms)
})
}
export const wordsCount = (text: string, isHtml = true): number => {
try {
return wordsCounter(text, { isHtml }).wordsCount