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

Handle buildId mismatch properly #1221

Closed
wants to merge 6 commits into from

Conversation

arunoda
Copy link
Contributor

@arunoda arunoda commented Feb 20, 2017

Related to #786

In this case, we'll do a reload when we detect a buildId mismatch.
With the reload, it'll load the newest version of the app.

With this reload, it might destroy the app's state. So, we've a way to restore the state.

Let's assume our client side state stored in a variable called state. Then this is how we use reload hooks to restore the state .

let state = {}

Router.onBeforeReload = function (key) {
  localStorage.setItem(key, JSON.stringify(state))
}

Router.onAfterReload = function (key) {
  const data = (localStorage.getItem(key))
  if (!data) return

  const state = JSON.parse(data)
}

@rauchg
Copy link
Member

rauchg commented Feb 20, 2017

There's an issue with this approach. If the server is performing a partial rollout of new builds, the mismatch could trigger an infinite reload loop for the client.

@rauchg rauchg closed this Feb 20, 2017
@arunoda arunoda deleted the do-build-id-mismatch-reload branch February 20, 2017 21:05
@nkzawa
Copy link
Contributor

nkzawa commented Feb 20, 2017

I wonder if we can just get a new Build ID when the mismatch was detected, then you don't have to force users reload 🤔

@arunoda
Copy link
Contributor Author

arunoda commented Feb 20, 2017

@nkzawa Getting a new BUILD_ID is not the problem here.
See: https://github.com/zeit/next.js/wiki/Handle-BUILD_ID-Mismatch-Error

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants