1641512c94
Streamdown parses assistant markdown with allowDangerousHtml, so every `<tag>` run in a message goes to parse5 and then through hast-util-from-parse5, which recurses once per level of unclosed nesting. Past roughly 1,750 consecutive unclosed tags that overflows the call stack and throws RangeError out of the middle of a React render. Nemotron-3-ultra degenerates into exactly that: thousands of `<unk>` tokens emitted as reasoning, every one of them an element parse5 opens and never closes. The payload is persisted to the session, so the throw comes back on every reload. Clamp the depth of unclosed elements in the prose path and escape the opening `<` past the cap, leaving the text visible as the literal `<unk>` it always was. The bound is on depth, not size: 20,000 balanced `<b>x</b>` pairs and 20,000 void `<br>` tags parse fine because neither drives the tree deeper, so only unclosed elements are counted and normal markup is returned by identity.