[Flight] Support classes in renderDebugModel#33590
Merged
Merged
Conversation
e57882c to
a1dc769
Compare
unstubbable
approved these changes
Jun 22, 2025
| for (const propName in object) { | ||
| if (hasOwnProperty.call(value, propName) || isGetter(proto, propName)) { | ||
| // We intentionally invoke getters on the prototype to read any enumerable getters. | ||
| instanceDescription[propName] = object[propName]; |
Collaborator
There was a problem hiding this comment.
I'm a bit concerned that this might trigger unwanted side effects, like the getters on the "exotic" promises in Next.js.
Contributor
Author
There was a problem hiding this comment.
Yea, but for them to be discovered they have to be enumerable so the trick is to make them non-enumerable.
Getters are non-enumerable by default when defined by syntax and when added with defineProperty.
If anything the concerning bit might be the enumerability trap but that's a concern regardless.
Such as if the body contains native code.
a1dc769 to
0682cde
Compare
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
github-actions Bot
pushed a commit
that referenced
this pull request
Jun 22, 2025
This adds better support for serializing class instances as Debug
values.
It adds a new marker on the object `{ "": "$P...", ... }` which
indicates which constructor's prototype to use for this object's
prototype. It doesn't encode arbitrary prototypes and it doesn't encode
any of the properties on the prototype. It might get some of the
properties from the prototype by virtue of `toString` on a `class`
constructor will include the whole class's body.
This will ensure that the instance gets the right name in logs.
Additionally, this now also invokes getters if they're enumerable on the
prototype. This lets us reify values that can only be read from native
classes.
---------
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
DiffTrain build for [18ee505](18ee505)
github-actions Bot
pushed a commit
to shawfix/react
that referenced
this pull request
Jun 23, 2025
This adds better support for serializing class instances as Debug
values.
It adds a new marker on the object `{ "": "$P...", ... }` which
indicates which constructor's prototype to use for this object's
prototype. It doesn't encode arbitrary prototypes and it doesn't encode
any of the properties on the prototype. It might get some of the
properties from the prototype by virtue of `toString` on a `class`
constructor will include the whole class's body.
This will ensure that the instance gets the right name in logs.
Additionally, this now also invokes getters if they're enumerable on the
prototype. This lets us reify values that can only be read from native
classes.
---------
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
DiffTrain build for [18ee505](facebook@18ee505)
github-actions Bot
pushed a commit
to shawfix/react
that referenced
this pull request
Jun 23, 2025
This adds better support for serializing class instances as Debug
values.
It adds a new marker on the object `{ "": "$P...", ... }` which
indicates which constructor's prototype to use for this object's
prototype. It doesn't encode arbitrary prototypes and it doesn't encode
any of the properties on the prototype. It might get some of the
properties from the prototype by virtue of `toString` on a `class`
constructor will include the whole class's body.
This will ensure that the instance gets the right name in logs.
Additionally, this now also invokes getters if they're enumerable on the
prototype. This lets us reify values that can only be read from native
classes.
---------
Co-authored-by: Hendrik Liebau <mail@hendrik-liebau.de>
DiffTrain build for [18ee505](facebook@18ee505)
sebmarkbage
added a commit
that referenced
this pull request
Jun 23, 2025
…nformation (#33592) Stacked on #33588, #33589 and #33590. This lets us automatically show the resolved value in the UI. <img width="863" alt="Screenshot 2025-06-22 at 12 54 41 AM" src="https://github.com/user-attachments/assets/a66d1d5e-0513-4767-910c-5c7169fc2df4" /> We can also show rejected I/O that may or may not have been handled with the error message. <img width="838" alt="Screenshot 2025-06-22 at 12 55 06 AM" src="https://github.com/user-attachments/assets/e0a8b6ae-08ba-46d8-8cc5-efb60956a1d1" /> To get this working we need to keep the Promise around for longer so that we can access it once we want to emit an async sequence. I do this by storing the WeakRefs but to ensure that the Promise doesn't get garbage collected, I keep a WeakMap of Promise to the Promise that it depended on. This lets the VM still clean up any Promise chains that have leaves that are cleaned up. So this makes Promises live until the last Promise downstream is done. At that point we can go back up the chain to read the values out of them. Additionally, to get the best possible value we don't want to get a Promise that's used by internals of a third-party function. We want the value that the first party gets to observe. To do this I had to change the logic for which "await" to use, to be the one that is the first await that happened in user space. It's not enough that the await has any first party at all on the stack - it has to be the very first frame. This is a little sketchy because it relies on the `.then()` call or `await` call not having any third party wrappers. But it gives the best object since it hides all the internals. For example when you call `fetch()` we now log that actual `Response` object.
This was referenced Jun 23, 2025
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.
This adds better support for serializing class instances as Debug values.
It adds a new marker on the object
{ "": "$P...", ... }which indicates which constructor's prototype to use for this object's prototype. It doesn't encode arbitrary prototypes and it doesn't encode any of the properties on the prototype. It might get some of the properties from the prototype by virtue oftoStringon aclassconstructor will include the whole class's body.This will ensure that the instance gets the right name in logs.
Additionally, this now also invokes getters if they're enumerable on the prototype. This lets us reify values that can only be read from native classes.