pthrasher / snockets

Sprockets-style script concatenation for Node
119 stars 39 forks source link

Snockets output is dependent on file list ordering when using require_tree #32

Closed kamui closed 11 years ago

kamui commented 12 years ago

require_tree uses fs.readdir and fs.readdirSync, but snockets doesn't sort these files before it does the concatenation. This is causing an issue for me because I'm using my app with Heroku. I have 2 dynos running and both are generating different static assets with different static asset md5 hashes. Depending on which dyno you hit, you might get a 404 when you request a specific asset. I believe that each dyno is doing it's require_tree in a different order, therefore the content and hash ends up being different.

coen-hyde commented 11 years ago

Unfortunately this pull request won't solve the issue. The problem is the files are required asynchronously, which means they can be included in any order. I've hacked snockets to do this synchronously. See https://github.com/coen-hyde/snockets/tree/sort