-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Dev Server crashes if saving before the last rebuild complete #6919
Comments
Just happens occasionally. @pcattori Happens most often editing a heavy page like this one if you want to use it to debug https://github.com/manawiki/core/blob/home-page/app/routes/_index/index.tsx |
@xHomu could you patch You could do: if (build.assets === undefined) {
// console.log(JSON.stringify(build, undefined, 2)); // uncomment this line to debug
return;
} and then you could try to see what builds that are missing assets look like |
@xHomu This looks like it might be the same/similar as something I reported in #6831. I had a large server bundle size and would occasionally have file reading issues because the server was triggered by chokidar to re-read the bundle before the writing finished. Does removing the |
@ngbrown restart on every change would be a big hit on the DX, so I'm gonna give the awaitWriteFinish option a try and see if it helps. Just |
@xHomu The default timeout for |
@ngbrown no crushes in an afternoon after the change, a good sign! chokidar
.watch(BUILD_PATH, {
ignoreInitial: true,
awaitWriteFinish: { stabilityThreshold: 200 },
})
``` |
@pcattori I thought of another way to handle this than using |
With #6772 , we are now writing @ngbrown agree that doing an atomic move is a good solution, but it adds some complexity to the compiler. Not a lot, but some, so trying to see if we can use |
Sure let me give that a shot today. Should I go ahead and close pr #6922 until we settle on best practices? |
Just made it into a Draft PR for now |
@pcattori I pushed the WATCH_PATH change to mana.wiki and seems to be working at least as well as watching BUILD_PATH, will report back if we saw any instability manawiki/mana@2b81f4d#comments so far so good |
I'm also seeing this. Will try the suggested fix above (watching metafile.server.json) |
Mhm, experiencing some weird hmr not refreshing issues with one of the remix-v2-dev branches with |
Watching The HMR also seemed to stop working as the new chunks aren't loading. I'm on Remix 1.19.2. My reading of this is that the metadata is written out before the bytes in the remix/packages/remix-dev/compiler/server/compiler.ts Lines 143 to 147 in 8779b24
|
It's really strange, it works just fine on some of my repos, and not others. ✔️ mana.wiki (cjs/server.ts) https://github.com/manawiki/core remix-v2-server:
My presumption that was this was particular to specific typescript/ esm combination turns out to be wrong, or else there's no reason why mana and repay works but the cjs/server.ts branch of remix-v2-server didn't. @ngbrown Have you tried adding awaitWriteFinish back in and see if it do anything on your end? That seems to have helped, which indicates to me some weird race condition issue. After adding |
@xHomu Adding back in |
Oh yea, good point. I forgot that we are manually writing the server build file later and not depending on |
For now, let's rely on |
chokidar
.watch(BUILD_PATH, {
ignoreInitial: true,
awaitWriteFinish: { stabilityThreshold: 200 },
}) ... solved this for me as well (and I was also seeing the |
My new idea is to have a |
Ok version Technically, there's still a chance of a race condition, but should be much rarer plus I have additional plans to fix that. But for now you should be able to watch chokidar
- .watch(buildPath, { ignoreInitial: true })
+ .watch(path.resolve("build/version.txt"), { ignoreInitial: true })
.on("add", handleServerUpdate)
.on("change", handleServerUpdate); |
Something came up atm, but I'll be able to give it a whirl tonight. |
@pcattori happy to report back that all status looks green, and none of the repos I'm actively maintaining experience any of the previous downsides! ✔️ mana.wiki (cjs/server.ts) https://github.com/manawiki/core remix-v2-server:
Also seems a tad faster too? Might just be happy thoughts. Sample PR |
After v2 releases, we can update the templates to watch for |
Update chokidar to resolve a rare race condition issue that resultant in dev server crashing. This PR remix-run/remix#7299 sets up a fix where we can watch the version.txt file for changes (rather than build/index.js directly) to avoid race condition.
@chankruze the fixes were merged after v2.0.0. they are available on nightly ( |
What version of Remix are you using?
v1.19.0
Are all your remix dependencies & dev-dependencies using the same version?
Steps to Reproduce
This is somewhat inconsistent, since it depends in part how quickly your server rebuilds.
This most frequently occurs when working on our production apps with longer rebuild time (https://github.com/manawiki/starrail) and CTRL+S save rapidly before rebuilds are ready.
The error usually looks like this:
I'll try to see if I can create a reproducible step with a simpler template.
Expected Behavior
Dev Server crashes gracefully.
Actual Behavior
Dev Server crash and force a manual restart.
The text was updated successfully, but these errors were encountered: