rsnext/packages
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
..
create-next-app v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
eslint-config-next v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
eslint-plugin-next v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
font v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next Fix Router Error Events in Shallow Routing by Skipping cancelHandler Creation (#61771) 2024-02-28 05:39:31 -08:00
next-bundle-analyzer v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-codemod v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-env v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-mdx v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-plugin-storybook v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-polyfill-module v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-polyfill-nomodule v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
next-swc v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
react-refresh-utils v14.1.1-canary.78 2024-02-28 12:09:02 +00:00
third-parties v14.1.1-canary.78 2024-02-28 12:09:02 +00:00