HTMLRewriter breaks if a tag exceeds 3MBs in size

We are using cloudflare workers for some HTML transformations using HTMLRewriter and we have noticed that HTMLRewriter breaks with no exception while parsing HTML if the size of a tag goes above 3MBs in size.
We specifically face this problem in cases when HTMLRewriter tries to parse a html page that contains img tag with src attribute containing base64 encoded image that exceeds 3MBs in size, it breaks and does not parse any html post that point and just returns whatever transformation was completed till that point.
Since we don’t get any exception either, there’s no way for us to skip the culprit tag and move on to other transformations.