Skip to content

Commit 857b2de

Browse files
authoredOct 5, 2024
feat: add console warning for icon load timeout (#266)
1 parent eb577a9 commit 857b2de

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/runtime/components/shared.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { computed } from 'vue'
22
import { loadIcons, getIcon as _getIcon } from '@iconify/vue'
3+
import { consola } from 'consola'
34
import type { IconifyIcon } from '@iconify/types'
45
import type { NuxtIconRuntimeOptions } from '../../types'
56
import { useAppConfig } from '#imports'
@@ -19,7 +20,10 @@ export async function loadIcon(name: string, timeout: number): Promise<Required<
1920
.catch(() => null)
2021

2122
if (timeout > 0)
22-
await Promise.race([load, new Promise<void>(resolve => setTimeout(() => resolve(), timeout))])
23+
await Promise.race([load, new Promise<void>(resolve => setTimeout(() => {
24+
consola.warn(`[Icon] loading icon \`${name}\` timed out after ${timeout}ms`)
25+
resolve()
26+
}, timeout))])
2327
else
2428
await load
2529

0 commit comments

Comments
 (0)