Vagrant localhost installation stop working from yesterday on «handle_missing_cache» function in app/controllers/stylesheets_controller.rb

(Discourse.PRO) #1

Problem commit is: fix stylesheet cache to recover if file is on disk · discourse/discourse@96dbeb8 · GitHub

All pages simply hang up and stop loaded.
I quick fixed it commenting the line 27 out in app/controllers/stylesheets_controller.rb:

# handle_missing_cache(location, target, digest)

Console log ends with:

D, [2015-05-22T20:48:59.868520 #1387] DEBUG – : Category Load (2.2ms) SELECT
"categories".* FROM “categories” WHERE (background_url IS NOT NULL)
D, [2015-05-22T20:49:01.260618 #1387] DEBUG – : StylesheetCache Exists (3.1ms
) SELECT 1 AS one FROM “stylesheet_cache” WHERE “stylesheet_cache”.“target” =
‘desktop’ AND “stylesheet_cache”.“digest” = ‘c9c14e5297d1084b58510d7cbf956109a4
63942e’ LIMIT 1
D, [2015-05-22T20:49:01.269997 #1387] DEBUG – : (1.7ms) BEGIN
D, [2015-05-22T20:49:01.314477 #1387] DEBUG – : SQL (13.7ms) INSERT INTO “st
ylesheet_cache” (“content”, “created_at”, “digest”, “target”, “updated_at”) VALU
ES ($1, $2, $3, $4, $5) RETURNING “id” [[“content”, "@charset “UTF-8”;\n/*! n
ormalize.css v3.0.1 | MIT License | anishathalye (Anish Athalye) · GitHub */\n/\n * 1. Set default
font family to sans-serif.\n * 2. Prevent iOS text size adjust after orientation
change, without disabling\n * user zoom.\n /\n/ line 9, /vagrant/app/asset
s/stylesheets/vendor/normalize.scss /\nhtml {\n font-family: sans-serif;\n /
1 /\n -ms-text-size-adjust: 100%;\n / 2 /\n -webkit-text-size-adjust: 100
%;\n /
2 */\n}\n\n/
\n * Remove default margin.\n /\n/ line 19, /vagrant/ap
p/assets/stylesheets/vendor/normalize.scss /\nbody {\n margin: 0;\n}\n\n/ HTM
L5 display definitions\n =====================================================
===================== */\n/\n * Correct block display not defined for any HT
ML5 element in IE 8/9.\n * Correct block display not defined for details or
summary in IE 10/11 and Firefox.\n * Correct block display not defined for main in IE 11.\n /\n/ line 43, /vagrant/app/assets/stylesheets/vendor/normali
ze.scss */\narticle,\naside,\ndetails,\nfigcaption,\nfigure,\nfooter,\nheader,\n
hgroup,\nmain,\nnav,\nsection,\nsummary {\n display: block;\n}\n\n/
\n * 1. Co
rrect inline-block display not defined in IE 8/9.\n * 2. Normalize vertical al
ignment of progress in Chrome, Firefox, and Opera.\n /\n/ line 55, /vagrant/
app/assets/stylesheets/vendor/normalize.scss /\naudio,\ncanvas,\nprogress,\nvid
eo {\n display: inline-block;\n /
1 /\n vertical-align: baseline;\n / 2 *
/\n}\n\n/\n * Prevent modern browsers from displaying audio without controls
.\n * Remove excess height in iOS 5 devices.\n /\n/ line 65, /vagrant/app/asse
ts/stylesheets/vendor/normalize.scss */\naudio:not([controls]) {\n display: non
e;\n height: 0;\n}\n\n/
\n * Address [hidden] styling not present in IE 8/9/
10.\n * Hide the template element in IE 8/9/11, Safari, and Firefox < 22.\n /
line 76, /vagrant/app/assets/stylesheets/vendor/normalize.scss /\n[hidden]
,\ntemplate {\n display: none;\n}\n\n/
Links\n =============================
============================================= */\n/\n * Remove the gray backgr
ound color from active links in IE 10.\n /\n/ line 87, /vagrant/app/assets/sty
lesheets/vendor/normalize.scss */\na {\n background: transparent;\n}\n\n/
\n *
Improve readability when focused and also mouse hovered in all browsers.\n /\n
line 96, /vagrant/app/assets/stylesheets/vendor/normalize.scss /\na:active,
na:hover {\n outline: 0;\n}\n\n/
Text-level semantics\n ====================
====================================================== */\n/\n * Address styli
ng not present in IE 8/9/10/11, Safari, and Chrome.\n /\n/ line 107, /vagrant/
app/assets/stylesheets/vendor/normalize.scss */\nabbr[title] {\n border-bottom:
1px dotted;\n}\n\n/
\n * Address style set to bolder in Firefox 4+, Safari,
and Chrome.\n /\n/ line 116, /vagrant/app/assets/stylesheets/vendor/normalize.
scss */\nb,\nstrong {\n font-weight: bold;\n}\n\n/\n * Address styling not pr
esent in Safari and Chrome.\n /\n/ line 124, /vagrant/app/assets/stylesheets/v
endor/normalize.scss */\ndfn {\n font-style: italic;\n}\n\n/
\n * Address vari
able h1 font-size and margin within section and article\n * contexts in Fi
refox 4+, Safari, and Chrome.\n /\n/ line 133, /vagrant/app/assets/stylesheets
/vendor/normalize.scss /\nh1 {\n font-size: 2em;\n margin: 0.67em 0;\n}\n\n/
*\n * Address styling not present in IE 8/9.\n /\n/ line 142, /vagrant/app/ass
ets/stylesheets/vendor/normalize.scss */\nmark {\n background: #ff0;\n color:
000;\n}\n\n/\n * Address inconsistent and variable font size in all browsers.
\n /\n/ line 151, /vagrant/app/assets/stylesheets/vendor/normalize.scss */\nsm
all {\n font-size: 80%;\n}\n\n/
\n * Prevent sub and sup affecting line-h eight in all browsers.\n /\n/ line 160, /vagrant/app/assets/stylesheets/vendo

(Mittineague) #2


This has been perplexing me for nine days now off and on (mostly on :sadpanda:)

I’ve tried all sorts of things and every once in a while it would seem like I accidently did something right, but then back to problems.

I didn’t know if it was an update, WindowsOS, my dev environment, my WIP plugins, apps running in the background, ports being used by a few IDEs I recently uploaded, etc. or what.

(Discourse.PRO) #3

I see that StylesheetCache.add method is used not only from the place (handle_missing_cache) I mention above, but from some other places too, and it also can freeze page.
The better (but also quick and dirty) fix for Vagrant / localhost is to disable stylesheet insertion to database at all by changing line 10 in app/models/stylesheet_cache.rb from

success = create(target: target, digest: digest, content: content)


success = true

(Mittineague) #4

I don’t run in production mode, only development.
I’m guessing that most of the caching is done during “assets:precompile” (production only) but maybe not.

I’ll try running a few days and if I get any more hangs hacking the model too. for now it seems like hacking the controller was enough, though I think Sam would know best here.

(Sam Saffron) #5

production mode will ONLY work after asset:precompile runs.

(Mittineague) #6

Rather than hacking Core files (IMHO almost always a bad idea) I’ve been experimenting with just what it takes leaving the Core alone

  • open Git
  • open shell
  • run vagrant up
  • run vagrant ssh
  • run bundle install
  • run bundle exec rake db:migrate
  • run bundle exec rails s
  • open localhost:4000 in Chrome
  • close browser
  • Close machine in VirtualBox manager
  • run vagrant up
  • run vagrant ssh
  • run bundle exec rails s
  • open localhost:4000 in Chrome

I have found that when I add / delete / edit I need to repeat

  • close browser
  • Close machine in VirtualBox manager
  • run vagrant up
  • run vagrant ssh
  • run bundle exec rails s
  • open localhost:4000 in Chrome

but otherwise (no changes made) I can close down and restart without any problems.
(I’m guessing it is HTMLbars wanting to recompile after changes are made that is causing the hang)

Of course, while developing plugins I am always making changes, but depending on your frustration threshold this may be better than you hacking any Core files

(Mittineague) #7

Good News (knock wood)

I upgraded my Ubuntu from 12 to 14 and so far no more hangs! :fireworks: