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
Hot reloading breaks after one minute with the Next.js starter #131
Comments
@symmb this operating system and browser are you using? |
I'm on openSUSE Leap 15.3 and I've tested it on both Google Chrome (Version 103.0.5060.114) and Firefox (91.10.0esr). |
same problem for me on macos 12.4 with Chrome Version 103.0.5060.114 (Official Build) (arm64) |
Sorry about this experience – @mfix-stripe let me know if you need any support from the Next.js side. |
Ayy, thanks for offering @leerob! I don't think anything special is going on in our plugin that could cause this to happen, so feels like a Next.js specific bug to me. Especially since our plugin mimics the MDX plugin almost identically: https://github.com/vercel/next.js/blob/canary/packages/next-mdx/index.js Would happily accept your help! Cc'ing @ijjk in case something jumps out at him (since he just took a look at our plugin this week). |
Taking an initial look I'm not able to reproduce the HMR failing after a certain amount of time, it may be related to certain files being edited. To ensure webpack is tracking any files referenced the different loader dependencies can be added for example here's how it is managed in the postcss loader https://github.com/vercel/next.js/blob/8b721227cf82a0af3be07663dc8d218430c80514/packages/next/build/webpack/loaders/postcss-loader/src/index.js#L89-L103 |
Thanks for taking a look @ijjk. We do currently add a context dependency to the entire I am actually fairly certain this is the problem: vercel/next.js#19230 and vercel/next.js#12149 We used to force a page refresh on save in @ijjk do you have any suggested work arounds for this? |
@ijjk any thoughts on the above? Is there a idiomatic way to force |
Hmm we do have a test for server import changes triggering the data to be refreshed client-side without reloading here, if we could track down a test case for this we could investigate patching this easier. |
@ijjk super strange, but I was actually able to reproduce this issue with our starter repo: https://github.com/markdoc/markdoc-starter If you boot up the repo, HMR/Fast Refresh works great. But if you wait a few minutes and try to make edits, it no longer works. Is this enough of a repro for you? I can try to write a test for this, but not sure how I would at the moment |
Are you able to reproduce this on the bare Next.js starter from |
@ijjk it happens with the plain Next.js starter too. Here is a repo that reproduces the issue: https://github.com/mfix-stripe/nextjs-hmr-repro If you wait a minute or 2 and then try and edit the |
Ah I see, thanks for narrowing in on that! I was able to track this down to an issue with our entries handling and opened a fix/regression test for this in vercel/next.js#39845 |
As noticed in markdoc/markdoc#131 it seems we are incorrectly disposing active entries causing HMR to fail after the configured `maxInactiveAge`. To fix this instead of only updating lastActiveTime for one compiler type's entry we update all active compiler types for the active entry. This also updates an existing test to catch this by waiting the `maxInactiveAge` before attempting a change that should trigger HMR. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` Fixes: markdoc/markdoc#131
Hi, this should now be fixed in |
Thanks @ijjk! I just tested this with |
Can confirm it works with the latest Next.js canary + Markdoc. Thanks to everyone involved! |
What happened?
Whenever I run
npm run dev
and leave the page untouched in the browser and editor for about a minute, hot reloading doesn't have an effect anymore. The Next.js reload indicator in the lower right corner still shows up but the page does not update when I change something in my sources. Refreshing the page or performing any sort of page navigation (without a full reload) fixes hot reloading until it breaks again after one minute.To reproduce
npm install
npm run dev
Version
0.1.4
Additional context
The exact commit of the starter repository used is cf36368f405a41499aded8b61b136c0bda44c0e3.
This problem doesn't occur with a Next.js starter project without Markdoc, so it doesn't seem to be a Next.js issue.
I'm also not seeing any errors or warnings in the browser console or network tab.
The text was updated successfully, but these errors were encountered: