I am building a Cloudflare Worker that uses HTMLRewriter to parse some items out of an HTML stream.
Since the HTML stream can be quite long, when I have found the last item I am looking for I would like stop further action from HTMLRewriter and return my JSON response immediately.
I looked into throwing an error to achieve this but that seems to get logged as a failure case in the analytics.
Is there a better way to early-exit HTMLRewriter and still return a JSON response?