From 8f7c304d5852ecdeb556085f211c4369bd861b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 17 Jun 2025 20:25:21 +0200 Subject: [PATCH] Fix crash when rendering ogimage with invalid icon (#3348) --- packages/gitbook/src/routes/ogimage.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/gitbook/src/routes/ogimage.tsx b/packages/gitbook/src/routes/ogimage.tsx index f79b86948..4d8a83b2c 100644 --- a/packages/gitbook/src/routes/ogimage.tsx +++ b/packages/gitbook/src/routes/ogimage.tsx @@ -160,14 +160,12 @@ export async function serveOGImage(baseContext: GitBookSiteContext, params: Page height: 48, }; - if ('icon' in customization.favicon) - return ( - Icon - ); + if ('icon' in customization.favicon) { + const faviconImage = await fetchImage(customization.favicon.icon[theme], faviconSize); + if (faviconImage) { + return Icon; + } + } return (