You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Streaming HTML hangs if the target's original document is destroyed while a parser-blocking script is pending #13205
After streamHTMLUnsafe({ runScripts: true }) on an element in an iframe's document, the element can be moved to another document and streaming continues there. But when a streamed parser-blocking script is pending, the parser resumes from a task tied to the iframe's document:
Queue a global task on the DOM manipulation task source given the parser's script target document's relevant global object to perform the following steps:
Execute the pending parsing-blocking scripts for this parser.
If this parser's aborted is false, then run a fragment parser given this parser.
The script target document is set once, to the context document, when the stream is created. A task whose document isn't fully active isn't runnable, so if the iframe is removed before that task runs, the parser never resumes, and nothing aborts it. As far as I can tell, the rest of the content is never inserted and close() never settles:
// div is in iframe.contentDocumentconstwriter=div.streamHTMLUnsafe({runScripts: true}).getWriter();awaitwriter.write('<script src="slow.js"></script><p>after</p>');document.body.append(div);iframe.remove();awaitwriter.close();// never settles
Maybe the task could use the target's current node document's relevant global object, or the parser could be aborted, rejecting close(), when the script target document stops being fully active.
(Found while comparing #12758 with a rewrite of it, zcorpan#1.)
I think aborting would be better. If you stream into an element in an active document and it's destroyed half way, it's a bit like an "abort" condition.
Activity
zcorpan commentedon Nov 6, 2026
@noamr
noamr commentedon Nov 8, 2026
I think aborting would be better. If you stream into an element in an active document and it's destroyed half way, it's a bit like an "abort" condition.