This repository was archived by the owner on Feb 6, 2023. It is now read-only.
Fix race condition in website builder script#1031
Merged
Daniel15 merged 1 commit intofacebookarchive:masterfrom Feb 26, 2017
Merged
Fix race condition in website builder script#1031Daniel15 merged 1 commit intofacebookarchive:masterfrom
Daniel15 merged 1 commit intofacebookarchive:masterfrom
Conversation
There was a race condition in the website generation script. It calls convert.js to convert Markdown to JavaScript, and then immediately looks for the resulting js files. However, convert.js uses the async version of `glob()`. This means that the code in generate.js that looks for these files can execute **before** the conversion in convert.js finishes, resulting in no pages being built. When this happens on TravisCI, it deletes all the pages on the site, due to the `rm -Rf *` in `publish.sh`. I've simply switched convert.js to use the synchronous version of `glob()` so that it's guaranteed to finish before the generation happens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a race condition in the website generation script (
generate.js). It callsconvert.jsto convert Markdown to JavaScript, and then immediately looks for the resulting JavaScript files. However,convert.jsuses the async version ofglob(). This means that the code in generate.js that looks for these files can execute before the conversion in convert.js finishes, resulting in no pages being built. When this happens on TravisCI, it deletes all the pages on the site, due to therm -Rf *inpublish.sh.I've simply switched
convert.jsto use the synchronous version ofglob()so that it's guaranteed to finish before the generation happens.This diff looks large, but most of it is changing the indentation level as the code is no longer in a callback.
References #1029