Pattern
Callback-Based HTML Serialization
callback-based-html-serialization
Lexbor HTML serialization is callback/stream-driven, so writing to a file fails when developers try to dump DOM output after the callback boundary; the fix is to serialize to disk via the provided write callback or persist the produced buffer immediately.