Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
barjin committed Jan 6, 2025
1 parent 55210ec commit d5e469a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/basic-crawler/src/internals/basic-crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,9 +980,11 @@ export class BasicCrawler<Context extends CrawlingContext = BasicCrawlingContext
* All the tasks active at the time of calling this method will be allowed to finish.
*/
stop(message: string = 'This crawler has been gracefully stopped.') {
// Gracefully starve the this.autoscaledPool, so it doesn't start new tasks. Resolves once the pool is cleared.
this.autoscaledPool
?.pause() // Gracefully starve the this.autoscaledPool, so it doesn't start new tasks. Resolves once the pool is cleared.
.then(async () => this.autoscaledPool?.abort()) // Resolves the `autoscaledPool.run()` promise in the `BasicCrawler.run()` method. Since the pool is already paused, it resolves immediately and doesn't kill any tasks.
?.pause()
// Resolves the `autoscaledPool.run()` promise in the `BasicCrawler.run()` method. Since the pool is already paused, it resolves immediately and doesn't kill any tasks.
.then(async () => this.autoscaledPool?.abort())
.then(() => this.log.info(message))
.catch((err) => {
this.log.error('Error stopping the crawler:', err);
Expand Down

0 comments on commit d5e469a

Please sign in to comment.