Fix: added missing await keywords in storeProject (#1731)

Though we don't return any value, we should wait till we've completed
the file I/O. This likely caused the flake from #1655. As we didn't
await the write, it caused a race condition where we tried to read first.

Fixes #1655
This commit is contained in:
Robin van Boven 2020-03-30 22:28:37 +02:00 committed by GitHub
parent eb205e8680
commit 8ca62d6e0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -45,18 +45,18 @@ export class DataDirectory implements CacheProvider, ProjectStorageProvider {
const fileName = path.join(projectDirectory, name); const fileName = path.join(projectDirectory, name);
await fs.writeFile(fileName, data); await fs.writeFile(fileName, data);
}; };
writeFile("project.json", stringify(projectToJSON(project))); await writeFile("project.json", stringify(projectToJSON(project)));
if (weightedGraph) { if (weightedGraph) {
writeFile( await writeFile(
"weightedGraph.json", "weightedGraph.json",
stringify(WeightedGraph.toJSON(weightedGraph)) stringify(WeightedGraph.toJSON(weightedGraph))
); );
} }
if (cred) { if (cred) {
writeFile("cred.json", stringify(cred.toJSON())); await writeFile("cred.json", stringify(cred.toJSON()));
} }
if (pluginDeclarations) { if (pluginDeclarations) {
writeFile( await writeFile(
"pluginDeclarations.json", "pluginDeclarations.json",
stringify(pluginsToJSON(pluginDeclarations)) stringify(pluginsToJSON(pluginDeclarations))
); );