diff --git a/packages/next/client/link.tsx b/packages/next/client/link.tsx index 0abf7018cb5877d..9f846681accb0d1 100644 --- a/packages/next/client/link.tsx +++ b/packages/next/client/link.tsx @@ -209,11 +209,15 @@ class Link extends Component { if (!this.p || typeof window === 'undefined') return // Prefetch the JSON page if asked (only in the client) const [href, asPath] = this.getPaths() - // make sure to catch here since we should handle an unhandledRejection - // since we're doing this automatically and we don't want to reload the - // page while automatically prefetching for the user and this only occurs - // when doing an actual navigation - Router.prefetch(href, asPath, options).catch(() => {}) + // We need to handle a prefetch error here since we may be + // loading with priority which can reject but we don't + // want to force navigation since this is only a prefetch + Router.prefetch(href, asPath, options).catch(err => { + if (process.env.NODE_ENV !== 'production') { + // rethrow to show invalid URL errors + throw err + } + }) prefetched[href] = true }