Fix unfurl timeout

This commit is contained in:
Alex Gleason 2023-08-30 21:40:52 -05:00
parent b9fc663db4
commit 54481ab96b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 1 deletions

View File

@ -217,7 +217,10 @@ interface PreviewCard {
async function unfurlCard(url: string): Promise<PreviewCard | null> {
console.log(`Unfurling ${url}...`);
try {
const result = await unfurl(url, { fetch, follow: 2, timeout: Time.seconds(1), size: 1024 * 1024 });
const result = await unfurl(url, {
fetch: (url) => fetch(url, { signal: AbortSignal.timeout(Time.seconds(1)) }),
});
return {
type: result.oEmbed?.type || 'link',
url: result.canonical_url || url,