remix icon indicating copy to clipboard operation
remix copied to clipboard

old build files not cleaned up automatically in dev mode

Open akiran opened this issue 2 years ago • 12 comments

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.

akiran avatar Mar 21 '22 18:03 akiran

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

jelofsson avatar Mar 23 '22 17:03 jelofsson

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

axel-planfox avatar Mar 23 '22 17:03 axel-planfox

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

kelleyperry avatar Apr 02 '22 18:04 kelleyperry

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

haach avatar May 11 '22 20:05 haach

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.

thomasverleye avatar May 12 '22 06:05 thomasverleye

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. https://github.com/remix-run/remix/blob/15213866f8dca94e6164c46028f410625226599f/packages/remix-dev/cli/commands.ts#L226-L237

dmarkow avatar Jun 10 '22 09:06 dmarkow

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

eladchen avatar Oct 21 '22 11:10 eladchen

any solution?

image

qaynam avatar Oct 21 '22 13:10 qaynam

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

kiliman avatar Oct 21 '22 14:10 kiliman

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.

qaynam avatar Oct 21 '22 14:10 qaynam

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

kiliman avatar Oct 21 '22 15:10 kiliman

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

https://github.com/evanw/esbuild/issues/139 https://github.com/evanw/esbuild/commit/268f8331f5b3840e659c600b9ddf797b3a147018 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?

eladchen avatar Oct 22 '22 08:10 eladchen

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

universse avatar Nov 15 '22 10:11 universse

Fixed by #5223

pcattori avatar Jan 23 '23 19:01 pcattori

🤖 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[bot] avatar Jan 24 '23 07:01 github-actions[bot]

🤖 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!

github-actions[bot] avatar Jan 30 '23 23:01 github-actions[bot]