fix(core): better error logging on SSR/dev failures + log stacktraces and error causes#8872
Merged
fix(core): better error logging on SSR/dev failures + log stacktraces and error causes#8872
Conversation
slorber
commented
Apr 7, 2023
Comment on lines
247
to
251
| // TODO this logger thing is annoying | ||
| // This makes it impossible to use native logging of nested stacktraces | ||
| // ie the error causes are not logged here | ||
| // It seems we can't have colors + nested stacktrace logging at the same time | ||
| logger.error(err instanceof Error ? err.stack : err); |
Collaborator
Author
There was a problem hiding this comment.
@Josh-Cena this thing is a bit annoying because if an error is thrown with a cause it won't print the cause
Collaborator
There was a problem hiding this comment.
I believe we can use the built-in error logging? This code has been there forever, and I think it's fine at this point to remove it and just use console.log(err) instead
Collaborator
Author
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Size Change: +306 B (0%) Total Size: 1.01 MB
ℹ️ View Unchanged
|
Collaborator
Author
|
Let's give it a try. Not sure I'll backport this, looks a bit risky although I'd be happy to have better error logging in the v2.x releases. We'll see if it works great first |
This was referenced Oct 19, 2023
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.

Motivation
Currently when a React component fails to render, we have bad error messages related to chalk (see #8826 (comment)):
For some reason when using chalk inside the Webpack
serverEntry.tsxwe have issues (looks related to unability to resolve properly "ansi-styles" package). I was not able to fix this issue so simply removed the usage of chalk inserverEntry.tsxI also did some cleanup in the way we output Webpack stats errors/warnings in start/build.
Test Plan
CI and local tests in both dev/prod mode
DOCUSAURUS_CRASH_TEST=true yarn build:website:fastSome additional notes.