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

Browser requests to files in mounted filesystem not completing #178

Open
Munawwar opened this issue Jul 12, 2016 · 4 comments
Open

Browser requests to files in mounted filesystem not completing #178

Munawwar opened this issue Jul 12, 2016 · 4 comments

Comments

@Munawwar
Copy link

Munawwar commented Jul 12, 2016

The problem: When using mounted directory as static file root with expressjs, browser requests to files doesn't seem to complete. Tested on Chrome.
An example is attached - test-fusile.zip. To run the exmaple, first do npm install, then node_modules/fusile/bin/fusile-bin.js http-src/ http-dev/. Then on a second terminal run node server.js.


I believe the problem is caused by a wrong Content-Length HTTP header size, which in turn causes browser to wait forever. Expressjs sets Content-Length to size of file, and fusile seems to return the wrong file size due to this line -> https://github.com/Munter/fusile/blob/master/lib/index.js#L176.

@Munawwar
Copy link
Author

Munawwar commented Jul 22, 2016

My proposed solution to this:
Step 1: If a transpile-able file is being read or stats'ed, compile it and cache the size and timestamp. From what I see the OS file manager doesn't recursively stats the mounted directory. It only goes through the top/first level files/directories.
Step 2: If any of those file changes, recompile that file and update cache.
Step 3: When exiting fusile, save the cache to a .fusile.json file, which will be reloaded when fusile is started the next time (Check for file updates there, since cache could be outdated).
This still makes fusile better than a 'clone directory + file watchers' solution at least.

@Munter
Copy link
Owner

Munter commented Jul 22, 2016

I think we're going to switch it back to compile on stat. With an on-disk cache so it can persist across instances. But this time around I need to be sure I can write tests that actually cover more things. I'll meet with @papandreou to talk that through

@Munawwar
Copy link
Author

If you need any help or don't have time to complete this, ping me. I guess I am more in need of this issue being resolved than yourself :)

@Munter
Copy link
Owner

Munter commented Jul 23, 2016

We just had a bit of a code sprint and wrote a file system backed cache with much of the same basic plumbing than fusile, just better thought through. With a file system backed cache I should be able to rewrite fusile to compile on stat without to much of a start up penalty. That should fix the problem of wrongly reported file lengths.

https://github.com/assetgraph/skrin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants