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

Don't delete .next folder before a replacement is built #1139

Merged
merged 1 commit into from
Feb 14, 2017
Merged

Don't delete .next folder before a replacement is built #1139

merged 1 commit into from
Feb 14, 2017

Conversation

thomaslindstrom
Copy link
Contributor

@thomaslindstrom thomaslindstrom commented Feb 14, 2017

Solves #1135.

On build, sequentially:

  1. Leaves the current state .next as is
  2. Builds the new state into a random .next-6c15581c-e852-...
  3. Renames the old state .next to a random .next-5c523d99-4375-...
  4. Renames the new state .next-6c15581c-e852-... to .next, efficiently replacing the current state
  5. Removes the old state .next-5c523d99-4375-...
  6. (This is where you'd restart the next.js process)

On deploy (using eg. pm2), this led my current app to have, a total down time of virtually nothing, instead of being down for several minutes.

The problem was, in the current state of next.js, that the entire .next directory suddenly disappeared when my next.js process was still running and using the files in it, which made it crash and display Internal Server Error (the _error.js disappeared, too...).

With this solution, there's virtually no down time when deploying.

@rauchg
Copy link
Member

rauchg commented Feb 14, 2017

Brilliant. Atomicity ftw

@rauchg rauchg merged commit acc1983 into vercel:master Feb 14, 2017
*.sublime-*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed this. I don't think we should have an editors section. gitignore is for artifacts of the project itself, not user systems

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed it myself, sorry. But I don't think I added that line? Must have been EOL.

@thomaslindstrom
Copy link
Contributor Author

Thanks, @rauchg!

@nkzawa
Copy link
Contributor

nkzawa commented Feb 14, 2017

I think the build folder should be created in temp dir otherwise it remains when build failed.

@rauchg
Copy link
Member

rauchg commented Feb 14, 2017 via email

@nkzawa
Copy link
Contributor

nkzawa commented Feb 14, 2017

I dont know when you want to keep failed .next-xxx on your app folder.

@rauchg
Copy link
Member

rauchg commented Feb 14, 2017 via email

@nkzawa
Copy link
Contributor

nkzawa commented Feb 14, 2017

Possibly. though I think we can print the path when failed instead since you have no idea what .next-xxx is anyway. I just want to make sure it doesnt remain when I cancelled the build.

@rauchg
Copy link
Member

rauchg commented Feb 14, 2017 via email

@nkzawa nkzawa mentioned this pull request Feb 15, 2017
@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