rsnext/test/development/pages-dir/client-navigation
Remo Vetere 3790099997
Fix Router Error Events in Shallow Routing by Skipping cancelHandler Creation (#61771)
### Problem

We've identified a bug within Next.js's pages router when utilizing the
shallow routing API, specifically when invoking `router.push` with the
`{ shallow: true }` option, like so:
 
```javascript
router.push('/?counter=10', undefined, { shallow: true });
```

Shallow routing is designed to update the URL without running data
fetching methods such as getServerSideProps, getStaticProps, or
getInitialProps. However, a side effect of this process is that it skips
the clean-up of the cancelHandler. This leads to router error events
being fired erroneously, causing confusion and potential stability
issues, as the system behaves as if an error occurred when, in fact,
none did.
 
### Solution

This PR addresses the issue by modifying the shallow routing logic to
also skip the creation of the cancelHandler. Given that shallow routing
operations are synchronous and do not involve data fetching or other
asynchronous tasks that might need to be canceled, the cancelHandler is
unnecessary in this context.

fixes #61772

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-02-28 05:39:31 -08:00
..
fixture Fix Router Error Events in Shallow Routing by Skipping cancelHandler Creation (#61771) 2024-02-28 05:39:31 -08:00
index.test.ts Fix Router Error Events in Shallow Routing by Skipping cancelHandler Creation (#61771) 2024-02-28 05:39:31 -08:00
rendering.ts Update swc_core to v0.87.28 (#60876) 2024-01-24 08:05:05 +00:00