mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:01:09 +02:00
fix(search): fix TypeScript errors in extract service
- Remove unsupported signal option from article-extractor - Use Promise.race for timeout handling instead - Remove non-existent language property from ArticleData https://claude.ai/code/session_01Rk3YVJCU3nM8uvVPghRz6r
This commit is contained in:
parent
bd72b4d6d5
commit
c0802af67f
1 changed files with 8 additions and 4 deletions
|
|
@ -70,9 +70,14 @@ export class ExtractService {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const article = await extract(request.url, {
|
// Use Promise.race for timeout since extract doesn't support AbortSignal
|
||||||
signal: AbortSignal.timeout(request.options?.timeout || this.defaultTimeout),
|
const timeout = request.options?.timeout || this.defaultTimeout;
|
||||||
});
|
const extractPromise = extract(request.url);
|
||||||
|
const timeoutPromise = new Promise<null>((_, reject) =>
|
||||||
|
setTimeout(() => reject(new Error('Extraction timeout')), timeout),
|
||||||
|
);
|
||||||
|
|
||||||
|
const article = await Promise.race([extractPromise, timeoutPromise]);
|
||||||
|
|
||||||
if (!article) {
|
if (!article) {
|
||||||
return this.buildErrorResponse(
|
return this.buildErrorResponse(
|
||||||
|
|
@ -102,7 +107,6 @@ export class ExtractService {
|
||||||
readingTime: Math.ceil(this.countWords(text) / 200),
|
readingTime: Math.ceil(this.countWords(text) / 200),
|
||||||
|
|
||||||
ogImage: article.image,
|
ogImage: article.image,
|
||||||
language: article.language,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Optional: Markdown conversion
|
// Optional: Markdown conversion
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue