title: Firefox splits up Express response readableStream sometimes
body: <p>I'm trying to stream HTML strings from my Express backend using a series of response.write for the sense of <i>real-time</i> updating, since I'm doing some HTTP requests in the middle, then appending them to the DOM. I'm extracting a pseudocode fragment from a given Wiki page as part of my response for context. </p>
  
  <p>Everything is working fine in Chrome however Firefox seems to <b>sometimes</b> split the stream into two, obviously then not being able to parse a HTML string as it gets split half way through a tag. </p>
  
  <p>Again, sometimes Firefox takes the larger response as a whole and works fine but most often it splits it. </p>
  
  <p>Is this something to do with Firefox's reading of readableStream's vs Chrome? Or am I missing something in my code?</p>
  
  <p><b>Edit:</b> <a href="https://i.stack.imgur.com/2uCGu.png" rel="nofollow noreferrer">How the stream gets split</a> (too low rep to imbed)</p>
  
  <p>Stream being sent:</p>
  
  <pre class="lang-js prettyprint-override"><code>
  res.write(`&lt;p class="update"&gt;&amp;#8594; Fetching page content...&lt;/p&gt;`);
  
  //Querying Wiki API here (code not shown)
  
  //returning parsed HTML
  parsed_frag = parsed_frag.replace(/\\n/g, '&lt;br /&gt;');
  
  res.write(`&lt;p class="program"&gt;&amp;#8594; Fragment ${frag_num + 1} for ${response.data.parse.displaytitle}:&lt;/p&gt;`);
  res.write(`&lt;div id="0" class="result"&gt;${parsed_frag}&lt;/div&gt;`);
  res.write(`&lt;p class="program"&gt;&amp;#8594; (C = copy to clipboard, N = next fragment, R = restart)&lt;/p&gt;`);
  res.write(`&lt;div class="program"&gt;~/pseudo-fetcher&lt;div id="key-input" class="input key-input" contenteditable="true"&gt;&lt;/div&gt;&lt;/div&gt;`);
  
  res.status(200).end();
  </code></pre>
  
  <p>The parsed_frag variable holds the extracted HTML in a string. I want the whole thing to be read as a single part, rather than randomly split when read. Since I'm using res.write beforehand, res.send isn't useful.</p>