-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Fast refresh not working properly due to page reload when compiling middleware #31827
Comments
I was able to reproduce this, Developer Experience when using middleware is bad, the fast refresh won't work properly (editing a simple changes will get a full reload), hope this can get further investigation |
Possibly related: #30791 |
I thought #31548 would fix this issue, but I am experiencing the same at the latest v.12.0.7 |
This comment has been minimized.
This comment has been minimized.
This has been fixed, please upgrade |
@balazsorban44, which version resolves this issue? |
🤔 I just tried it locally. Maybe I'm missing something? |
Sorry. Could you try |
If anyone else still having issues, please open a separate bug report with a reproduction. |
Sorry, just tried |
To reproduce, add some JSX and save your project, repeat 4 - 5 times and you should get a reload. |
Yeah, still no problem on my side. 👀 Could you link to your repository? Create a minimal reproduction? |
I don't have a TMDB API key, but for the sake of pinning down where the problem might be, it is favorable if you could provide an isolated/minimal reproduction anyway. |
Hey! I was facing the same issue until I found the problem: something that is imported in the middleware and somewhere in the app. The import could be anything, including an external dependency. Here is the minimal reproduction: henriqemalheiros/middleware-fast-refresh. To reproduce it, though, you need to wait ~20 seconds after the page is fully loaded or the last change was made. If you make a change before the ~20 seconds interval, the fast refresh works as expected. After that, any change to any part of the app triggers a full refresh. There is a warning logged to the console, but it's to fast to actually read it. In
|
@henriqemalheiros nice work! this has been really hurting my productivity, thanks for coming up with a reproduction. |
Hi, As a temporary solution is to have different functions with the same logic and then import them separately into both files(your react component and _middleware.js) Does anyone know how to solve this to use the same function in both places? |
This is pretty frustrating and severely hindering the development experience. Every time I update code it does a full refresh to a blank page and I have to refresh twice to get it to render. I have imports in my _middleware – there's not really much I can do to get around that. Can I disable re-compilation on a particular nextjs path? That file isn't changing at all, it should be compiled once until any changes are made. |
Also seeing frequent reloads with With This is just doing/undoing the same change to a styled component over and over which works like 3 in 4 times, and does a full reload 1 in 4. I see My middleware is just the basic auth example and is totally self contained, except for importing TS types: I can confirm that removing My project is too large and complex to share as a repro, but if no one else has created one I can try and create one. |
I ran into the same issue after upgrading to |
@WoutGroenendijk you must still have |
@tomduncalf Yes I still got |
@tomduncalf is there any chance you are importing
@WoutGroenendijk that's what I did as well:
became
It solved the problem, but that makes the app harder to maintain and it is a change impossible to be made when importing other things, like a dependency ( |
Good question @henriqemalheiros, I’m not sure why I’d be importing them elsewhere but it’s possible, I’ll check. Hopefully this issue can be resolved soon anyway, feels like going back to the dark ages with full page refresh 😂 |
Yup, definitely not fixed on 12.0.9.
As soon as I remove any module imports - the problem is gone. |
Same here on
|
Hello @balazsorban44, I just created a quick reproduction repository : https://github.com/bmichotte/next-issue-31827 With that project cloned, you have to
|
Just tried and now we need to close this annoying notice "About to perform a pull refresh" in addition to page refreshing 😆 |
Hi friends! Just want to say that we are aware of this issue on the next.js core team and are working towards getting a fix out. Really appreciate your patience here, and so sorry to everyone who this has inconvenienced! |
…_module (#33873) fixes #31827 ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
Hi, this has been updated in |
@ijjk I can confirm that I don't see the complete refresh in the two projects I tested with that version ! |
Can also confirm this is fixed. Thank you so so so much!! |
HI, we are using a custom server.js . Upgrading to EDIT: we are not using any kind of middleware. |
@GandharvJaggi if you are not using middleware then this sounds unrelated to your issue, can you open a separate issue with a reproduction to allow investigation? |
I tried v12.0.11-canary.10 and I still get a lot of those but in the context of using MDX files. Would you mind considering an option to disable this big alert box, and reload automatically? Or is there an easy to do it already?
When starting in dev mode, I noticed this message relate to fast refresh and a "custom loader", though I'm not sure what it is:
Thank you |
@sebastienbarre could you open a fresh issue with a reproduction so we can investigate this case? It seems different from the original issue here. |
x-ref: #31827 x-ref: #34212 ![image](https://user-images.githubusercontent.com/1365881/151994766-b9afb349-1a9a-4220-9387-de10165e34e3.png) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` Co-authored-by: JJ Kasper <[email protected]>
…_module (vercel#33873) fixes vercel#31827 ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint`
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
What version of Next.js are you using?
12.0.4
What version of Node.js are you using?
16.13.0
What browser are you using?
Chrome, Safari, Edge
What operating system are you using?
macOS
How are you deploying your application?
next dev
Describe the Bug
Since I don't know the technological background or necessity of the page reload for
middleware
, I'm not sure if that's something that you have to live with when working withmiddleware
- but any change, like edits made to react components, often trigger a page reload due to themiddleware
being compiled:This becomes especially frustrating when working with
getStaticProps
.Expected Behavior
No page reload when applying changes ("Fast Refresh").
To Reproduce
Basic
middleware
implementation.The text was updated successfully, but these errors were encountered: