Skip to content

Commit

Permalink
Emit Server Error Prefix in the .stack Property Too (#28738)
Browse files Browse the repository at this point in the history
Follow up to #28684.

V8 includes the message in the stack and printed errors include just the
stack property which is assumed to contain the message. Without this,
the prefix doesn't get printed in the console.

<img width="578" alt="Screenshot 2024-04-03 at 6 32 04 PM"
src="https://github.com/facebook/react/assets/63648/d98a2db4-6ebc-4805-b669-59f449dfd21f">

A possible alternative would be to use a nested error with a `cause`
like #28736 but that would need some more involved serializing since
this prefix is coming from the server. Perhaps as a separate attribute.

DiffTrain build for [583eb67](583eb67)
  • Loading branch information
sebmarkbage committed Apr 4, 2024
1 parent ce3ba22 commit 2d93439
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20e710aeab3e03809c82d134171986ea270026a0
583eb6770d56e9793d3660bd9c6782fdebc93729
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactDOMServer-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "19.0.0-www-classic-81cf15cb";
var ReactVersion = "19.0.0-www-classic-6ac6cbda";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -11516,7 +11516,7 @@ if (__DEV__) {
? "Switched to client rendering because the server rendering aborted due to:\n\n"
: "Switched to client rendering because the server rendering errored:\n\n";
boundary.errorMessage = prefix + message;
boundary.errorStack = stack;
boundary.errorStack = stack !== null ? prefix + stack : null;
boundary.errorComponentStack = thrownInfo.componentStack;
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiled/facebook-www/ReactDOMServer-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (__DEV__) {
var React = require("react");
var ReactDOM = require("react-dom");

var ReactVersion = "19.0.0-www-modern-e2470d87";
var ReactVersion = "19.0.0-www-modern-53247bf3";

// This refers to a WWW module.
var warningWWW = require("warning");
Expand Down Expand Up @@ -11437,7 +11437,7 @@ if (__DEV__) {
? "Switched to client rendering because the server rendering aborted due to:\n\n"
: "Switched to client rendering because the server rendering errored:\n\n";
boundary.errorMessage = prefix + message;
boundary.errorStack = stack;
boundary.errorStack = stack !== null ? prefix + stack : null;
boundary.errorComponentStack = thrownInfo.componentStack;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11316,7 +11316,7 @@ if (__DEV__) {
? "Switched to client rendering because the server rendering aborted due to:\n\n"
: "Switched to client rendering because the server rendering errored:\n\n";
boundary.errorMessage = prefix + message;
boundary.errorStack = stack;
boundary.errorStack = stack !== null ? prefix + stack : null;
boundary.errorComponentStack = thrownInfo.componentStack;
}
}
Expand Down

0 comments on commit 2d93439

Please sign in to comment.