| 721 | // The stream must END with incomplete UTF-8 bytes, so the final decode() produces output |
| 722 | |
| 723 | async function* generateWithTrailingIncomplete(): AsyncGenerator<Uint8Array> { |
| 724 | // Valid complete XML |
| 725 | yield new TextEncoder().encode("<root>test</root>"); |
| 726 | // Trailing incomplete UTF-8: first byte of a 2-byte sequence with no continuation |
| 727 | // This byte will be buffered during streaming decode and flushed at the end |
| 728 | yield new Uint8Array([0xC2]); // Incomplete 2-byte sequence (expects 0x80-0xBF to follow) |
| 729 | } |
| 730 | |
| 731 | // The XML parser will see the replacement character after the closing tag |
| 732 | // which causes "Cannot have content after the root element" |