-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fiber] Enable Native console.createTask Stacks When Available #29223
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
*/ | ||
|
||
import ReactSharedInternals from 'shared/ReactSharedInternals'; | ||
import {enableOwnerStacks} from 'shared/ReactFeatureFlags'; | ||
|
||
let suppressWarning = false; | ||
export function setSuppressWarning(newSuppressWarning) { | ||
|
@@ -36,14 +37,20 @@ export function error(format, ...args) { | |
} | ||
} | ||
|
||
// eslint-disable-next-line react-internal/no-production-logging | ||
const supportsCreateTask = __DEV__ && enableOwnerStacks && !!console.createTask; | ||
|
||
function printWarning(level, format, args) { | ||
// When changing this logic, you might want to also | ||
// update consoleWithStackDev.www.js as well. | ||
if (__DEV__) { | ||
const isErrorLogger = | ||
format === '%s\n\n%s\n' || format === '%o\n\n%s\n\n%s\n'; | ||
|
||
if (ReactSharedInternals.getCurrentStack) { | ||
if (!supportsCreateTask && ReactSharedInternals.getCurrentStack) { | ||
// We only add the current stack to the console when createTask is not supported. | ||
// Since createTask requires DevTools to be open to work, this means that stacks | ||
// can be lost while DevTools isn't open but we can't detect this. | ||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this by design? Because I couldn't find any mention of this on web Assuming that logs are buffered, we should expect that users will end up having different stack traces, depending on if browser DevTools are opened or not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the DevTools are not open, then there will only be the stack for the current callsite and not the "async stack". If that bottoms out inside React then effectively you have no stack trace. This is not really new to It's unfortunate for React because we don't actually bother calling User space dialogs would still be able to show stacks since they get our |
||
const stack = ReactSharedInternals.getCurrentStack(); | ||
if (stack !== '') { | ||
format += '%s'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoxyq I disabled the appending this way to detect if we already have a native async stack. Ideally we could detect if this was actually an "active" task somehow (i.e. the Chrome DevTools was opened at the time).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for flagging. We could potentially look if RDT frontend is connected to RDT backend at this stage, which would mean that browser DevTools are opened for the extension case.
Would that work or do you need to know if browser DevTools are opened at the stage of task creation?