Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router.back() and history.back() is not working (popstate event triggered but event.state.....) #29177

Closed
aslanon opened this issue Sep 17, 2021 · 10 comments
Labels
bug Issue was opened via the bug report template.

Comments

@aslanon
Copy link

aslanon commented Sep 17, 2021

What version of Next.js are you using?

9.3.5

What version of Node.js are you using?

v10.18.0

What browser are you using?

Chrome

What operating system are you using?

macOs

How are you deploying your application?

other platform

Describe the Bug

I am using Router.push. And when using this method page is opening. It's working. But when use browser back button, Router.back or history.push() is updating URL but not navigating to it in browser and page is not opening. But page URL is updating.

image

"next-routes": "^1.4.2",

Expected Behavior

Changing the URL, opening the page

To Reproduce

use browser back button

@aslanon aslanon added the bug Issue was opened via the bug report template. label Sep 17, 2021
@aslanon aslanon changed the title Router.back, history.back is not working (popstate event triggered but event.state did not have url or as https://err.sh/zeit/next.js/popstate-state-empty overrideMethod @ react_devtools_backend.js:4049 Router.onPopState @ router.js:106) Router.back, history.back is not working (popstate event triggered but event.state.....) Sep 17, 2021
@aslanon aslanon changed the title Router.back, history.back is not working (popstate event triggered but event.state.....) Router.back() and history.back() is not working (popstate event triggered but event.state.....) Sep 17, 2021
@ijjk
Copy link
Member

ijjk commented Sep 18, 2021

Hi, this should be working correctly in the latest version of Next.js v11.1.2, please upgrade and give it a try! Note: we also have tests covering this behavior here which are passing.

@ijjk ijjk closed this as completed Sep 18, 2021
@aslanon
Copy link
Author

aslanon commented Sep 21, 2021

I'm upgrade my next version to v11.1.2 but I have new error in console. @ijjk

output
Error [ERR_METHOD_NOT_IMPLEMENTED]: The _write() method is not implemented at Writable._write (_stream_writable.js:566:6) at doWrite (_stream_writable.js:415:12) at clearBuffer (_stream_writable.js:545:7) at Writable.uncork (_stream_writable.js:319:7) at /Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1346:11 at /Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1330:7 at rhs (/Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1330:44) at /Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1348:5 at /Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1330:7 at Promise (/Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1361:5) at new Promise (<anonymous>) at piperToString (/Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1353:10) at Object.renderToHTML (/Users/aslanon/xxx/xxx.web/node_modules/next/server/render.tsx:1187:22)

@ijjk
Copy link
Member

ijjk commented Sep 21, 2021

Hmm are you seeing the same error in the latest canary v11.1.3-canary.26? Note this error is unrelated to the original so if persists might be good to open a new issue with minimal reproduction.

@aslanon
Copy link
Author

aslanon commented Sep 21, 2021

Yes, I have this version. @ijjk

image

@ijjk
Copy link
Member

ijjk commented Sep 21, 2021

Can you share the contents of the page you are seeing this error on?

@aslanon
Copy link
Author

aslanon commented Sep 21, 2021

it doesn't say which page is causing. But I suspect this page.

image

@ijjk
Copy link
Member

ijjk commented Sep 21, 2021

Oh this does look related to #28423

I would recommend against returning notFound: true there. If you are wanting to redirect in getStaticProps/getServerSideProps you can use the redirect field instead, related documentation https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering

@aslanon
Copy link
Author

aslanon commented Sep 26, 2021

I updated to the latest version of Next.Js. Currently there is no error in the console (browser and terminal), but the browser's back button does not work. The URL is updated but the content does not change. :( @ijjk

@ijjk
Copy link
Member

ijjk commented Sep 27, 2021

Hi, can you provide a repo with a minimal reproduction? This is most like related to user code and will require more information to provide further assistance.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

3 participants