From a5f13f2234bb6f611a83a7846755c16dddcda1ff Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 18 Feb 2020 15:10:58 -0600 Subject: [PATCH] Make sure to show prefetch error in development still --- packages/next/client/link.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 }