fix: pipe Next.js server stdout/stderr to debug log file#15065
Open
thesandlord wants to merge 1 commit intomainfrom
Open
fix: pipe Next.js server stdout/stderr to debug log file#15065thesandlord wants to merge 1 commit intomainfrom
thesandlord wants to merge 1 commit intomainfrom
Conversation
Previously, the Next.js standalone server output was only piped to context.logger.debug() which does not write to the .debug.log file. This made it impossible to diagnose server-side errors (e.g. 500s) from the debug log. Now, all stdout, stderr, process errors, and exit events from the Next.js server are written to the debug log via DebugLogger.logServerOutput(). This gives full visibility into server startup failures, rendering errors, and module resolution issues — especially useful for diagnosing Windows compatibility problems. Co-Authored-By: Sandeep Dinesh <sandeep@buildwithfern.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs: Related to fern-api/fern-platform#9752
Previously, the Next.js standalone server's stdout/stderr was only sent to
context.logger.debug(), which does not write to the~/.fern/logs/*.debug.logfile. This made it impossible to diagnose server-side errors (e.g. 500 responses, module resolution failures) from the debug log — only CLI-level structured events (reload, validation, memory) appeared there.Changes Made
DebugLogger.logServerOutput(stream, text)method that writes structured JSON entries withsource: "nextjs-server"and appropriate log levels ("error"for stderr,"debug"for stdout)runAppPreviewServer.tsto write to the debug log:stdoutdata (thecheckReadyhandler)stderrdataerroreventsexitevents"nextjs_server_output"to theCliMetricEventtype unionAll calls use
void(fire-and-forget) to avoid blocking server operation, matching the existing pattern for other debug logger calls.Review Checklist
"nextjs_server_output"was added toCliMetricEvent.type, butlogServerOutputwrites directly viawriteEntryrather than going throughlogCliMetric— the type union addition is not strictly necessary. Confirm this is acceptable or should be removed.appendFilecalls.Testing
fern docs dev)pnpm run check)Link to Devin session: https://app.devin.ai/sessions/384de2d2e741453fa07377d662b6e2c2
Requested by: @thesandlord