Skip to content
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
Daniel15:fix-web
Feb 26, 2017
Merged

Fix race condition in website builder script#1031
Daniel15 merged 1 commit intofacebookarchive:masterfrom
Daniel15:fix-web

Conversation

@Daniel15
Copy link
Contributor

@Daniel15 Daniel15 commented Feb 26, 2017

There was a race condition in the website generation script (generate.js). It calls convert.js to convert Markdown to JavaScript, and then immediately looks for the resulting JavaScript 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 diff looks large, but most of it is changing the indentation level as the code is no longer in a callback.

References #1029

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants