-
Notifications
You must be signed in to change notification settings - Fork 48.8k
[Flight] Serialize already resolved Promises as debug models #33588
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
base: main
Are you sure you want to change the base?
Conversation
920e9b8
to
e865e01
Compare
One thing to consider here is that calling It can also hide unhandled promise rejections. Adding two then listeners before it has a chance to run its downstream listeners can break async stack traces. So we might want to do something about the timing of when or if we call .then. |
One issue is that if you pass a Promise as props, and then await it later. It will have already been serialized in a halted form because we don't wait for the second time it occurs. It would probably be better to wait until the end of the stream to read all the promises in one tick. |
We already support serializing the values of instrumented Promises as debug values such as in console logs. However, we don't support plain native promises.
This waits a microtask to see if we can read the value within a microtask and if so emit it. This is so that we can still close the connection.
Otherwise, we emit a "halted" row into its row id which replaces the old "Infinite Promise" reference.
We could potentially wait until the end of the render before cancelling so that if it resolves before we exit we can still include its value but that would require a bit more work. Ideally we'd have a way to get these lazily later anyway.