rsnext/test/e2e/app-dir/app-prefetch
Janka Uryga 0fee50ed6e
fix: app-router prefetch crash when an invalid URL is passed to Link (#66755)
Closes [#66650](https://github.com/vercel/next.js/issues/66650)
Closes NEXT-3520

### What?

- Make Link not throw during prefetch if it received an invalid `href`
(see [#66650](https://github.com/vercel/next.js/issues/66650))
- Throw in dev mode if an invalid link was passed to `router.prefetch`
-- this matches current prod behavior
- (previously, we'd immediately exit out of `router.prefetch`, so the
user would see no indication that this'd fail in prod)

### Why?

If an invalid URL was passed to `<Link>`, the whole app would crash and
show "A client-side exception occurred". A failed prefetch should not
bring down the whole app.

Note that This preserves the current behavior of explicit
`router.prefetch(url)` throwing an error if `url` is invalid. We may
want to adjust this in the future, but that could be considered a
breaking change, so I'm leaving it out for now. This only affects
`Link`, which was intended to catch any errors thrown from
`router.prefetch`, but that bit was accidentally broken.
2024-06-11 21:36:27 +02:00
..
app fix: app-router prefetch crash when an invalid URL is passed to Link (#66755) 2024-06-11 21:36:27 +02:00
prefetching.stale-times.test.ts [Breaking] disable client router cache for page segments (#66039) 2024-05-21 13:54:23 -07:00
prefetching.test.ts fix: app-router prefetch crash when an invalid URL is passed to Link (#66755) 2024-06-11 21:36:27 +02:00