From eae94e0fd2d6af43b51ac14089292df6ce3565d2 Mon Sep 17 00:00:00 2001 From: cgeek <cem.moreau@gmail.com> Date: Sat, 30 Jun 2018 14:30:52 +0200 Subject: [PATCH] [fix] sync: let Duniter exit if an error occur during blocks retrieval --- app/modules/crawler/lib/sync.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/modules/crawler/lib/sync.ts b/app/modules/crawler/lib/sync.ts index 99598fa62..77b3c5640 100644 --- a/app/modules/crawler/lib/sync.ts +++ b/app/modules/crawler/lib/sync.ts @@ -143,7 +143,7 @@ export class Synchroniser extends stream.Duplex { !cautious, this.watcher) - downloader.start() + const startp = downloader.start() let lastPullBlock:BlockDTO|null = null; let syncStrategy = this.syncStrategy @@ -242,7 +242,10 @@ export class Synchroniser extends stream.Duplex { })(this.server, this.watcher, this.dal, this.BlockchainService) const logInterval = setInterval(() => this.logRemaining(to), EVAL_REMAINING_INTERVAL); - await dao.pull(this.conf, this.logger) + await Promise.all([ + dao.pull(this.conf, this.logger), + await startp // In case of errors, will stop the process + ]) // Finished blocks this.watcher.downloadPercent(100.0); -- GitLab