Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion functions/send-email-link/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ const fetchLogoAsBase64 = async (url: string | undefined): Promise<string | unde
logger.warn('Blocked unsafe URL for logo fetch', { url });
return undefined;
}
// Add timeout to prevent hanging on unresponsive servers
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 10000); // 10 second timeout

try {
const response = await fetch(url);
const response = await fetch(url, { signal: controller.signal });

if (!response.ok) return url;

const buffer = await response.arrayBuffer();
Expand All @@ -173,6 +177,8 @@ const fetchLogoAsBase64 = async (url: string | undefined): Promise<string | unde
} catch {
logger.warn('Failed to fetch logo for base64 encoding, using original URL', { url });
return url;
} finally {
clearTimeout(timeoutId);
}
};

Expand Down