diff --git a/packages/next/src/build/output/log.ts b/packages/next/src/build/output/log.ts index d24159ef3029c..eaf63aaac88a8 100644 --- a/packages/next/src/build/output/log.ts +++ b/packages/next/src/build/output/log.ts @@ -1,4 +1,5 @@ import { bold, green, magenta, red, yellow, white } from '../../lib/picocolors' +import { LRUCache } from '../../server/lib/lru-cache' export const prefixes = { wait: white(bold('○')), @@ -76,11 +77,12 @@ export function trace(...message: any[]) { prefixedLog('trace', ...message) } -const warnOnceMessages = new Set() -export function warnOnce(...message: any[]) { - if (!warnOnceMessages.has(message[0])) { - warnOnceMessages.add(message.join(' ')) +const warnOnceCache = new LRUCache(10_000, (message) => message.length) +export function warnOnce(...message: any[]) { + const key = message.join(' ') + if (!warnOnceCache.has(key)) { + warnOnceCache.set(key) warn(...message) } }