Skip to content

Commit

Permalink
fix(react-email): Null byte characters being rendered in the preview (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmfern committed Nov 13, 2024
1 parent e22559e commit 74d49e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-meals-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-email": patch
---

fix null byte characters being rendered in the preview server
5 changes: 4 additions & 1 deletion packages/react-email/src/actions/render-email-by-path.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/render/src/node/read-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export const readStream = async (
});
stream.pipe(writable);

return new Promise<string>((resolve, reject) => {
await new Promise<void>((resolve, reject) => {
writable.on("error", reject);
writable.on("close", () => {
resolve(result);
resolve();
});
});
}
Expand Down

0 comments on commit 74d49e5

Please sign in to comment.