Skip to content

Commit

Permalink
Make sure to show prefetch error in development still
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Feb 18, 2020
1 parent c5508c4 commit a5f13f2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/next/client/link.tsx
Expand Up @@ -209,11 +209,15 @@ class Link extends Component<LinkProps> {
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
}

Expand Down

0 comments on commit a5f13f2

Please sign in to comment.