Stop scraping in the middle of a route handler if some condition is met?

hey folks, basically the title, I want to stop scraping in the middle of a route handler if some conditon is met because the full function is a little expensive computationally.

I am using
return;
to exit the route handler when some condition is met but I am facing issues with the the node process hanging indefinitely after scraping is done. I had a previous thread using
crawler.teardown()
and how removing the return statement stopped the hanging issue.

But even in handlers where I am not calling
crawler.teardow()
, I am facing hanging issues.

is there a better way to accomplish this?
Was this page helpful?