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

old build files not cleaned up automatically in dev mode #2432

Closed
akiran opened this issue Mar 21, 2022 · 16 comments
Closed

old build files not cleaned up automatically in dev mode #2432

akiran opened this issue Mar 21, 2022 · 16 comments
Labels
bug:unverified feat:dx Issues related to the developer experience

Comments

@akiran
Copy link

akiran commented Mar 21, 2022

What version of Remix are you using?

1.1.3

Steps to Reproduce

Create a project with remix and continue to make changes in the projects. New build files with new hashes are generated on every code change. Build folder size continues to increase drastically over time as the old build files are not cleaned up.

Expected Behavior

Old and unused build files should be automatically removed to avoid a drastic increase in the build folder size

Actual Behavior

In #2425 discussion, @sergiodxa mentioned that this issue was fixed in #252
I tried stopping the remix dev server and re-started it. But the build folder is not cleaned up automatically.

Currently, my build folder size is 24 GB.

@jelofsson
Copy link

I have the same behavior, build folder is not cleaned up automatically.

@ghost
Copy link

ghost commented Mar 23, 2022

I have encountered the same issue. My workaround is to remove the two Remix output directories before starting the dev server.

@kelleyperry
Copy link

Screen Shot 2022-04-02 at 11 25 03 AM

@haach
Copy link

haach commented May 11, 2022

I am running into the same issue. Just cleaned out almost 10GB of files. 😱 Was there any progress on this?

@thomasverleye
Copy link
Contributor

For the contributors who would start on this, I did some testing and came up with following observation I posted in my duplicate ticket:

Been testing the watch function from the CLI Commands.
It seems like the exitHook can't be triggered properly.
See: https://github.com/remix-run/remix/blob/main/packages/remix-dev/cli/commands.ts#L222

When testing the exitHook inside the dev function, it does get triggered, so I'm afraid the watch function can't be run async and maybe should return a callback function instead closes everything correctly inside the dev function.

Not sure if that's a solid solution though.

@machour machour added the feat:dx Issues related to the developer experience label May 12, 2022
@dmarkow
Copy link
Contributor

dmarkow commented Jun 10, 2022

The issue is that exit-hook package doesn't support async code (yet), so as soon as resolve is called the process exits without waiting for the then block to execute.

let resolve: () => void;
exitHook(() => {
resolve();
});
return new Promise<void>((r) => {
resolve = r;
}).then(async () => {
wss.close();
await closeWatcher();
fse.emptyDirSync(config.assetsBuildDirectory);
fse.rmSync(config.serverBuildPath);
});

@eladchen
Copy link

eladchen commented Oct 21, 2022

@dmarkow the exit-hook package now support async code.

@qaynam
Copy link

qaynam commented Oct 21, 2022

any solution?

image

@kiliman
Copy link
Collaborator

kiliman commented Oct 21, 2022

I just add a "clean" script that runs before "dev" that deletes the build folders.

"clean": "rimraf build public/build",
"dev": "npm run clean && remix dev",

You'll need to add the rimraf package

@qaynam
Copy link

qaynam commented Oct 21, 2022

I just add a "clean" script that runs before "dev" that deletes the build folders.

"clean": "rimraf build public/build",
"dev": "npm run clean && remix dev",

You'll need to add the rimraf package

but what about hot reload ?
problem is every time source file got changed , remix bundler regenerate new version of JS(or css) file , but not clear build dir, it build different file to build dir over and over again.

@kiliman
Copy link
Collaborator

kiliman commented Oct 21, 2022

True. This is primarily so my build folders are not unbounded.

@eladchen
Copy link

eladchen commented Oct 22, 2022

This issue can be solved by using esbuild in-memory ("write: false" option).

evanw/esbuild#139
evanw/esbuild@268f833
https://esbuild.github.io/api/#write

When content is served by the remix request handlers, remix can lookup the resource within the in memory compilation
and in case one is not found look for the resource in the file system...

Using an in-memory would most likely result in faster compilations.

WDYT?

@universse
Copy link

not sure what the downsides are but what if the hashing of file names is disabled in dev mode?

@pcattori
Copy link
Contributor

Fixed by #5223

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-8346ace-20230124 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 1.12.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:unverified feat:dx Issues related to the developer experience
Projects
None yet
Development

No branches or pull requests