Skip to content

Conversation

@gabrielmfern
Copy link
Member

@gabrielmfern gabrielmfern commented Dec 10, 2025

I've always been annoyed at the fact that ora's spinners conflict with console.log statements during rendering, which sometimes, ends up eating away what you wanted to see in a console.log statement. To fix this, I've tried using process.stdout.cork and uncork, but console.err and console.warn write to process.stderr which is where ora also writes to, and corking will also buffer the spinner itself, which we don't want.

So, this just replaces the global console functions, storing the arguments to pass to the log function, and then once the spinner is done sends it all into the original function.


Summary by cubic

Prevents spinner output from overwriting console logs in the preview server by buffering logs during rendering and flushing them after the spinner stops.

  • New Features
    • Queue console.log/info/warn/error while the ora spinner runs, then flush and restore originals on success or error.
    • Send spinner output to stderr explicitly to avoid conflicts and ensure clean log output.

Written for commit 399acd0. Summary will update automatically on new commits.

@gabrielmfern gabrielmfern self-assigned this Dec 10, 2025
@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

🦋 Changeset detected

Latest commit: 399acd0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@react-email/preview-server Patch
react-email Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
react-email Ready Ready Preview Comment Dec 10, 2025 7:28pm
react-email-demo Ready Ready Preview Comment Dec 10, 2025 7:28pm

@gabrielmfern gabrielmfern marked this pull request as ready for review December 10, 2025 19:28
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/react-email/@react-email/preview-server@2725

commit: 399acd0

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/preview-server/src/actions/render-email-by-path.tsx">

<violation number="1" location="packages/preview-server/src/actions/render-email-by-path.tsx:76">
P1: Race condition: concurrent calls to `renderEmailByPath` can corrupt global console methods. When a second call starts before the first finishes, it captures the buffered function as `original` instead of the real console method. Consider storing the original console methods once at module scope, or using a reference counter to only restore when all concurrent calls complete.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

log,
uncork: uncorkLog,
original: originalLog,
} = createLogBufferer(console.log);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Race condition: concurrent calls to renderEmailByPath can corrupt global console methods. When a second call starts before the first finishes, it captures the buffered function as original instead of the real console method. Consider storing the original console methods once at module scope, or using a reference counter to only restore when all concurrent calls complete.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/preview-server/src/actions/render-email-by-path.tsx, line 76:

<comment>Race condition: concurrent calls to `renderEmailByPath` can corrupt global console methods. When a second call starts before the first finishes, it captures the buffered function as `original` instead of the real console method. Consider storing the original console methods once at module scope, or using a reference counter to only restore when all concurrent calls complete.</comment>

<file context>
@@ -52,12 +69,38 @@ export const renderEmailByPath = async (
+    log,
+    uncork: uncorkLog,
+    original: originalLog,
+  } = createLogBufferer(console.log);
+  console.log = log;
+  const {
</file context>
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants