Skip to content

Instantly share code, notes, and snippets.

@lefnire
Last active December 19, 2015 12:59
Show Gist options
  • Save lefnire/5959027 to your computer and use it in GitHub Desktop.
Save lefnire/5959027 to your computer and use it in GitHub Desktop.
Uncaught Error: Server and client page renders do not match

Bad:

app.get '/', (...) ->
  # This happens async, so page.render() is called at the same time. The server 
  # will generate a page with the outdated data, send to the client, which 
  # will generate a page with the updated data. Their checksums are different
  model.set "this", "that"
  page.render()

Good:

app.get '/', (...) ->
  # make page.render a callback instead
  model.set "this", "that", ->page.render()

Note: only an issue for model writes that hit the database. Private path writes are fine: model.set '_page.title', 'My Site'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment