docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

fix(core): fix React rendering null chars in HTML output - Use `renderToReadableStream`

Open slorber opened this issue 4 months ago • 4 comments

Motivation

Fix https://github.com/facebook/docusaurus/issues/9985

Replace renderToPipeableStream with renderToReadableStream because the former emit NULL chars unexpectedly, which might be a React bug.

Note: the setup is not super clean in terms of TS/exports, but it should work for all versions of Node we cover or the CI would report it.

Note: I benchmarked this locally and I doubt this has a significant impact on Docusaurus build times: it's approximately the same. The app rendering phase is not our main bottleneck currently, even with the new Docusaurus Faster options.

Related links:

  • React Core bug report: https://github.com/facebook/react/issues/31134
  • Bug repro: https://github.com/slorber/react-bug-repro-null-chars
  • Twitter conversations: https://x.com/sebastienlorber/status/1842252053390709058

Test Plan

CI

Test links

https://deploy-preview-10562--docusaurus-2.netlify.app/

slorber avatar Oct 07 '24 12:10 slorber