From 09a95b7597f18a889ac9fd2189820ce6ea6de9f7 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Wed, 25 Feb 2026 21:50:08 +0800 Subject: [PATCH] fix(plugin-md-power): fix timeout when retrieving remote image size (#860) --- plugins/plugin-md-power/src/node/enhance/imageSize.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/plugin-md-power/src/node/enhance/imageSize.ts b/plugins/plugin-md-power/src/node/enhance/imageSize.ts index 4a2cdede..d8f4f8a2 100644 --- a/plugins/plugin-md-power/src/node/enhance/imageSize.ts +++ b/plugins/plugin-md-power/src/node/enhance/imageSize.ts @@ -294,7 +294,7 @@ export function resolveImagePath(app: App, src?: string | null, currentPath?: st * @param src - Image URL / 图片 URL * @returns Image size / 图片尺寸 */ -function fetchRemoteImageSize(src: string): Promise { +async function fetchRemoteImageSize(src: string): Promise { const link = new URL(src) const promise = new Promise((resolve) => { @@ -313,9 +313,9 @@ function fetchRemoteImageSize(src: string): Promise { }) try { - return withTimeout(() => promise, 3000) - } - catch { - return Promise.resolve({ width: 0, height: 0 }) + return await withTimeout(() => promise, 3000) } + catch {} + + return { width: 0, height: 0 } }