deconst / presenter

Consumes the content store API to render HTML to humans
4 stars 6 forks source link

Deterministic template search path #110

Closed smashwilson closed 8 years ago

smashwilson commented 8 years ago

I strongly suspect that our 404 page woes are caused by globby returning results in a somewhat nondeterministic order. This is on production:

let ps = ['/usr/src/app/static/404',
  '/usr/src/app/static/404.html',
  '/usr/src/app/static/404.htm',
  '/usr/src/app/static/404/index.html',
  '/usr/src/app/static/404/index.htm',
  '/tmp/control-repo/templates/developer.rackspace.com/404',
  '/tmp/control-repo/templates/developer.rackspace.com/404.html',
  '/tmp/control-repo/templates/developer.rackspace.com/404.htm',
  '/tmp/control-repo/templates/developer.rackspace.com/404/index.html',
  '/tmp/control-repo/templates/developer.rackspace.com/404/index.htm']
globby.sync(ps)
[ '/usr/src/app/static/404.html',
  '/tmp/control-repo/templates/developer.rackspace.com/404.html' ]

Notice that we take matches[0] in the source, which is actually wrong for 404 templates if we assume that globby does preserve order: the control repository-provided custom 404 page's path will occur later. I can't verify it, but I'm guessing that occasionally, the results in matches are in the opposite order, hence production flapping between the two.

To be safe I'm taking out the globbing in favor of fs calls and explicit, predictable ordering.

This might fix #109 unless it doesn't.