fix(plugin-md-power): fix timeout when retrieving remote image size (#860)

This commit is contained in:
pengzhanbo 2026-02-25 21:50:08 +08:00 committed by GitHub
parent ce32605aee
commit 09a95b7597
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<ImgSize> {
async function fetchRemoteImageSize(src: string): Promise<ImgSize> {
const link = new URL(src)
const promise = new Promise<ImgSize>((resolve) => {
@ -313,9 +313,9 @@ function fetchRemoteImageSize(src: string): Promise<ImgSize> {
})
try {
return withTimeout(() => promise, 3000)
}
catch {
return Promise.resolve({ width: 0, height: 0 })
return await withTimeout(() => promise, 3000)
}
catch {}
return { width: 0, height: 0 }
}