mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
[Flight] Implement captureStackTrace and owner stacks on the Server (#30197)
Wire up owner stacks in Flight to the shared internals. This exposes it to `captureOwnerStack()`. In this case we install it permanently as we only allow one RSC renderer which then supports async contexts. Same thing we do for owner. This also ends up adding it to errors logged by React through `consoleWithStackDev`. The plan is to eventually remove that but this is inline with what we do in Fizz and Fiber already. However, at the same time we've instrumented the console so we need to strip them back out before sending to the client. This lets the client control whether to add the stack back in or allowing `console.createTask` to control it. This is another reason we shouldn't append them from React but for now we hack it by removing them after the fact.
This commit is contained in:
1 parent
8e9de898d3
commit
0b5835a46f
5 files changed
+221
-5
No files matched your search
@@ -40,6 +40,8 @@ export function error(format, ...args) {
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
const supportsCreateTask = __DEV__ && enableOwnerStacks && !!console.createTask;
|
||||
|
||||
export let isWritingAppendedStack = false;
|
||||
|
||||
function printWarning(level, format, args, currentStack) {
|
||||
// When changing this logic, you might want to also
|
||||
// update consoleWithStackDev.www.js as well.
|
||||
@@ -50,6 +52,7 @@ function printWarning(level, format, args, currentStack) {
|
||||
// can be lost while DevTools isn't open but we can't detect this.
|
||||
const stack = ReactSharedInternals.getCurrentStack(currentStack);
|
||||
if (stack !== '') {
|
||||
isWritingAppendedStack = true;
|
||||
format += '%s';
|
||||
args = args.concat([stack]);
|
||||
}
|
||||
@@ -60,5 +63,6 @@ function printWarning(level, format, args, currentStack) {
|
||||
// breaks IE9: https://github.com/facebook/react/issues/13610
|
||||
// eslint-disable-next-line react-internal/no-production-logging
|
||||
Function.prototype.apply.call(console[level], console, args);
|
||||
isWritingAppendedStack = false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user