vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.96k stars 26.87k forks source link

Links randomly not working and the Routing system is broken. (Let's Fix it) #27783

Closed Garamani closed 3 years ago

Garamani commented 3 years ago

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

v12.0.0

What browser are you using?

Chrome, Safari, Firefox (mobile and desktop)

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

Randomly, the links don't work; especially when the link I'm trying to open is more than simple text and images (pages with CSS animations and video).

What I have done so far to fix the issue:

Now, the front page has no video background with only a few texts and small images but the issue is still happening.

This is not some minor issue to get neglected. This is a serious issue that makes the website unusable.

There are so many similar issues and discussion topics opened by developers and the responses from the maintainers show that they have Underestimated the seriousness of this issue. Working Links are a vital part of each website. Don't forget that the reason that so many developers are using Next.js is to bring a better user experience at the end.

Some times ago I checked a website from a developer promoted by a tweet and the Links were not working. I told myself that maybe It's still under development and left the website. I didn't know that a refresh might help. this is a nightmare for any startup owner to lose their potential customers without even knowing that the website doesn't work properly.

SO, TAKE THIS ISSUE VERY SERIOUSLY, THE LINKS WERE WORKING SINCE THE INVENTION OF THE INTERNET

To show the amount of seriousness this is a screenshot showing the Vercel website itself has some issues opening links.

Screen Shot 2021-08-02 at 7 22 54 PM

However, there might be something wrong on my side. Let's fix the issue if you have any suggestions.

Expected Behavior

The Links should work as fast as possible with no unusual delay.

To Reproduce

I developed my website by following the next js tutorials and then I added some CSS animation, background videos, and state handling by useEffect, useState, useRef.

Garamani commented 3 years ago

Now I remember that I have downgraded the node to version 12 because the v14 was not compatible with React Native. Might be the source of this problem?!

wjd3 commented 3 years ago

Could you please link some related issues? This has never happened to me but I'm curious to learn more (if this issue is as widespread as you say it is).

leerob commented 3 years ago

Could you please provide a public repo with a reproduction so we can look into this? 🙏🏼 Thank you!

Garamani commented 3 years ago

Could you please link some related issues? This has never happened to me but I'm curious to learn more (if this issue is as widespread as you say it is).

https://github.com/vercel/next.js/issues/5598 https://github.com/vercel/next-plugins/issues/282 https://github.com/vercel/next.js/issues/5772 https://github.com/vercel/next.js/discussions/26356 https://github.com/vercel/next.js/discussions/27025

Garamani commented 3 years ago

Could you please provide a public repo with a reproduction so we can look into this? 🙏🏼 Thank you!

@leerob Thank you for your response, I will make a duplicate repo tomorrow to check if there is something wrong with the codes.

Garamani commented 3 years ago

@leerob This is the duplicate repo (only the content replaced): https://github.com/Garamani/next4test

I have deployed this to Vercel and after testing the same issue is happening.

To reproduce:

I don't know if it's a good idea to send the Vercel link here. I think you can deploy it yourself.

Thank you.

Garamani commented 3 years ago

In this video, you can see the issue.

https://user-images.githubusercontent.com/47912427/128506199-038958e2-8a0d-42cd-ae49-240f80633838.MOV

mina4gerges commented 3 years ago

👍

ijjk commented 3 years ago

Hi @Garamani is this happening in a specific environment/network connection or specific devices? I'm not able to reproduce this on desktop or mobile while throttling the network connection using the provided reproduction.

Also what was the latest canary you tried? The latest is v11.0.2-canary.27

Garamani commented 3 years ago

Hi @ijjk, Thanks for checking. Did you deploy the repo I've posted? the background video and CSS animations seem to be the problem. However, even after removing the background video, sometimes I experience this issue.

In my opinion, this might be related to prefetching. I don't know what's going on under the hood, but based on the behavior I guess the js codes are not loaded completely.

About your question about environment/network connection or specific devices, the Internet connection here in my country because of heavy filterings is not that stable, the devices I'm testing are MacBook pro 2017, iPhone 12 and redmi note 8(exprienced no issue with limited testing). I haven't experienced this kind of behavior on other websites such as Youtube. The Links always lead to something, clicking a Youtube link opens the page but because of poor internet connection doesn't play the video.

I think the Next.js Routing system needs some fundamental changes. The links should always open or produce some kind of error. The users expect the standard behavior, otherwise, they think the website has a problem(ruining a Company's Reputation) even though the cause of the error might be related to their poor internet connection.

I used the latest canary version, the node version is 12. (you can experience this issue more often on iOS version of Chrome) If you have any suggestions, I will try them and report back.

Thank you

Garamani commented 3 years ago

Upgraded to the latest canary version(11.0.2-canary.27). Same Issue.

After upgrading some warnings appeared. I added webpack 5, sass, node-sass, and acorn to devDependencies. the following warnings are still there(I think some are false warnings and some not necessary):

npm WARN eslint-config-next@11.0.1 requires a peer of next@>=10.2.0 but none is installed. You must install peer dependencies yourself. npm WARN eslint-config-next@11.0.1 requires a peer of typescript@>=3.3.1 but none is installed. You must install peer dependencies yourself. npm WARN next@11.0.2-canary.27 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself. npm WARN nextjs-progressbar@0.0.11 requires a peer of next@^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 but none is installed. You must install peer dependencies yourself. npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.

dev-ABsid commented 3 years ago

I'm also facing the same issue here -> https://abstack.pk/apps/poetry when I click on any poetry category, sometimes it loads and most of the time the loading get stuck(when i click on the link and the page isn't fully loaded yet). Both https://abstack.pk/apps/poetry and the next page is statically generated. If I open the link in a new tab the link is opening fine. I am using: "next": Version 11.0.1.

mattboon commented 3 years ago

Just noting that I too have seen this behaviour before in a Next app, but can't be more specific as to why/how it occurs I'm afraid.

Edit: It was also using the nprogress plugin same as your example above

Garamani commented 3 years ago

@mattboon Thank you. It's good to know the issue is happing in different regions and networks. I added the NProgress later to see if the links are working.

Brenndoerfer commented 3 years ago

I am experiencing the same.

I am using next 11.0.1 and it's deployed via Netlify. Even with only minor visual/ content changes after some deployments links don't work.

I noticed that after directly navigating to subpages, the entire website and links suddenly behave correctly. As if some chunks or code to get the site running properly is all loaded once I hit the subpages manually.

I wonder if it has something to do with using dynamic imports?

Deliaz commented 3 years ago

Having the same issue with "next": "^11.1.0". I have quite a simple code that pushes next page via router:

const href = `/${num}`;
router.push(href);

However, after some amount of navigations next hangs:

Screen Recording 2021-08-22 at 19 01 43 2021-08-22 19_16_48

With 100% CPU usage:

Screen Shot 2021-08-22 at 19 04 17
sidwebworks commented 3 years ago

Anything on this? We are facing the same issue during development

seastian commented 3 years ago

I am having the same problems too, specially on slow networks. What I did is disable prefetching on some of the links, seems to work (not ideal obviously)

alejandrojsn commented 3 years ago

We are currently facing this same issue. In our case we are not prefetching.

jonathanmcchesney commented 3 years ago

Our team is also seeing this issue, and we are prefetching our pages. Seems to occur randomly with the Link components as well as with router pushes. When we load /route1, then click a side bar to navigate to /route2 most times it will trigger a routeChangeStart event but it will never trigger a routeChangeComplete event. If a click the same link again we can see the routeChangeError being triggered with route cancelled, even if we waited several minutes before clicking again. Have tried several workarounds but no luck, this was not an issue we were seeing several next.js versions ago either.

hinsxd commented 3 years ago

We have this issue too. I found that if I click the link 5 seconds within page load, then the destination JS chunk can never load. But after 5 seconds it works normally

https://user-images.githubusercontent.com/8574962/131717225-caa64cc4-aa4a-4fa9-932d-5f5fafb28ff5.mov

akshaysura commented 3 years ago

we are facing this issue as well, when can this be fixed as it seems to linger no matter which next.js verions you use. Anyone from Next.js / Vercel care to comment?

doggodoge commented 3 years ago

This has become a serious blocking issue for our team. We've had to disable prefetching but this is a bandaid and negatively impacts app performance. I understand these issues can be hard to debug, but broken routing seriously impacts our ability to use next.js.

CaptainRemo commented 3 years ago

It is also blocking our team.

rauchg commented 3 years ago

We're giving this top priority folks! We'll keep you posted 🙂

timneutkens commented 3 years ago

Please try npm install next@canary in your application. This has been fixed in: https://github.com/vercel/next.js/releases/tag/v11.1.3-canary.14

Deliaz commented 3 years ago

Thank you for checking this! However, I just installed & tested 11.1.3-canary.14 and the problem still exists in my project. It is worth mentioning that I do not use links prefetch.

ijjk commented 3 years ago

@Deliaz can you create a new issue with a consistent reproduction showing this still being an issue on the latest canary of Next.js?

dtothefp commented 3 years ago

I think we are seeing this issue as well. Trying to upgrade to the canary but seeing errors I'm not sure how to debug when running next build on Webpack 5

info  - Using external babel configuration from /babel.config.js
Failed to parse source map: TypeError: Cannot read property 'sections' of null
    at _factory (/node_modules/@next/react-dev-overlay/node_modules/source-map/lib/source-map-consumer.js:1008:30)
    at new SourceMapConsumer (/node_modules/@next/react-dev-overlay/node_modules/source-map/lib/source-map-consumer.js:26:12)
    at /node_modules/@next/react-dev-overlay/lib/middleware.js:106:46
    at step (/node_modules/@next/react-dev-overlay/lib/middleware.js:33:23)
    at Object.next (/node_modules/@next/react-dev-overlay/lib/middleware.js:14:53)
    at /node_modules/@next/react-dev-overlay/lib/middleware.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/node_modules/@next/react-dev-overlay/lib/middleware.js:4:12)
    at findOriginalSourcePositionAndContent (/node_modules/@next/react-dev-overlay/lib/middleware.js:102:12)
ijjk commented 3 years ago

@dtothefp can you open a separate issue with a minimal reproduction to investigate the source map error?

dtothefp commented 3 years ago

@ijjk was able to resolve my issue, was a url path for font-face that no longer worked with mini-css-extract plugin.

I was able to update to 11.1.3-canary.15 and we are still intermittently seeing this issue upon router.push it seems there is some sort of timeout, a request is never made back to origin to /_next/data/<hash>/<page_name>.json

The result is a full page refresh and inability to navigate client side.

Do you any feedback on when we can expect an official NextJS release because most people at our organization don't feel comfortable running a canary in production?

jonathanmcchesney commented 3 years ago

Canary 14 seems like a major improvement within our app, we haven’t encountered the issue within our tests since the upgrade. But we can’t release our app without the next official next.js build, as I’m sure is the same for many if not all production or enterprise apps.

Is there an ETA of when the next official release is planned for?

leerob commented 3 years ago

Hey @jonathanmcchesney! Glad to hear it's been resolved for you. We're working hard to prepare for the next stable release. I don't have a firm date but we are aiming for release within the next few weeks.

dtothefp commented 3 years ago

@leerob @ijjk let me know if you would like me to open up a different issue but I was finally able to gather some info by adding some very rough debug logging into the file with the fix from

https://github.com/vercel/next.js/pull/28899/files#diff-a2b73fb1fea08f451ade0878c0bbfbd3e194992efdfcab41ea805e4287f6a73a

This issue only happens to us in some environments. We are uploading static assets to S3 and using NextJS assetPrefix to load them. What I see is upon client navigation an error in the value inside the promise.then callback block in the generator resolver that was updated in the PR fix for this issue

error: TypeError: Cannot read properties of undefined (reading 'call') at __webpack_require__ (https://<cdn_path>/_next/static/chunks/webpack-4e020f238f989630475d.js:25:43)
ijjk commented 3 years ago

@dtothefp I think a new issue would be good as this sounds like a different case than the original issue and will allow us to investigate the details specific to this new case more closely. A repo with a minimal reproduction would also help speed up investigation.

dtothefp commented 3 years ago

@ijjk thanks for the help, I think we're good on this. came from using a specific build id

generateBuildId: async () => process.env.SOME_VERSION

For some CI jobs this build id was not unique per CI build and combined with CDN caching of the build manifest stuff got out of whack with Webpack chunk loading resulting in failed client side navigation. It presented surprisingly like this GH issue so sorry about the confusion.

ijjk commented 3 years ago

@dtothefp I see, thanks for the info! Let us know if you notice any other issues around this.

balazsorban44 commented 2 years ago

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.