Skip to content

Commit

Permalink
fix: wait for storage to finish before resolving crawler.run()
Browse files Browse the repository at this point in the history
  • Loading branch information
B4nan committed Jul 28, 2022
1 parent 2beec9c commit 9d62d56
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/basic-crawler/src/internals/basic-crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,19 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
};
this.log.info('Crawl finished. Final request statistics:', stats);

const client = this.config.getStorageClient();

if (client.teardown) {
let finished = false;
setTimeout(() => {
if (!finished) {
this.log.info('Waiting for the storage to write its state to file system.');
}
}, 1000);
await client.teardown();
finished = true;
}

return stats;
}

Expand Down

0 comments on commit 9d62d56

Please sign in to comment.