Merge branch 'unfurl-timeout' into 'develop'

Fix unfurl timeout

See merge request soapbox-pub/ditto!31
This commit is contained in:
Alex Gleason 2023-08-31 02:43:11 +00:00
commit 7c2de9b2cf
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,