diff --git a/.changeset/clever-meals-vanish.md b/.changeset/clever-meals-vanish.md new file mode 100644 index 0000000000..01f4c6d9bd --- /dev/null +++ b/.changeset/clever-meals-vanish.md @@ -0,0 +1,5 @@ +--- +"react-email": patch +--- + +fix null byte characters being rendered in the preview server diff --git a/packages/react-email/src/actions/render-email-by-path.tsx b/packages/react-email/src/actions/render-email-by-path.tsx index e020917d71..11fa54da33 100644 --- a/packages/react-email/src/actions/render-email-by-path.tsx +++ b/packages/react-email/src/actions/render-email-by-path.tsx @@ -83,7 +83,10 @@ export const renderEmailByPath = async ( }); return { - markup, + // This ensures that no null byte character ends up in the rendered + // markup making users suspect of any issues. These null byte characters + // only seem to happen with React 18, as it has no similar incident with React 19. + markup: markup.replaceAll('\0', ''), plainText, reactMarkup, }; diff --git a/packages/render/src/node/read-stream.ts b/packages/render/src/node/read-stream.ts index 8c24dcfe37..be7b04b412 100644 --- a/packages/render/src/node/read-stream.ts +++ b/packages/render/src/node/read-stream.ts @@ -29,10 +29,10 @@ export const readStream = async ( }); stream.pipe(writable); - return new Promise((resolve, reject) => { + await new Promise((resolve, reject) => { writable.on("error", reject); writable.on("close", () => { - resolve(result); + resolve(); }); }); }