Skip to content

Commit 1407c6d

Browse files
authored
Merge pull request #13 from iswilljr/extract-metadata-timeout
feat: add timeout to extract metadata fetch request
2 parents 889f47b + 481a115 commit 1407c6d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/utils/metadata.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ function findTagTextContent(head: cheerio.Cheerio<cheerio.Element>, selectors: s
8686
}
8787

8888
export async function extractMetadata(url: string): Promise<ExtractedMetadata> {
89-
const res = await fetch(url)
89+
const timeoutSignal = AbortSignal.timeout(5000)
90+
const res = await fetch(url, { signal: timeoutSignal })
9091

9192
if (!res.ok) throw Error('Invalid response')
9293

0 commit comments

Comments
 (0)