next.js
8e7eb040 - Prevent unhandled rejections when a "use cache" cache handler errors (#95985)

Commit
125 days ago
Prevent unhandled rejections when a "use cache" cache handler errors (#95985) When a custom `"use cache"` cache handler's `get` method throws, the error was logged up to four times for a single request: once as the intended rendering error (`тип Error: ... { digest }`), and up to three more times through the various `unhandledRejection` handlers (the runtime's plain `console.error` in `process-error-handlers.ts`, the router server's `Log.error`, and the dev overlay's log forwarding). All the redundant logs stemmed from the same root cause: `ResolvableSharedCacheResult` stores its deferred promise in the dedup maps (`pendingCacheInvocations` / `crossRequestPendingCacheInvocations`) so concurrent invocations can join the leader. That promise has no consumer unless another invocation actually joins it, so when the leader's cache access failed, the rejected promise was left behind without a rejection handler, and Node.js reported it as an unhandled rejection that fanned out to every installed handler.
Author
Parents
Loading