-
Notifications
You must be signed in to change notification settings - Fork 49.1k
[Flight] Allow Temporary References to be awaited #34084
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
Conversation
Same as #33761 basically. I just saw it. I landed that one but rebased with my test/comment which has a bit more coverage. |
Comparing: 1d16396...9c79367 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
305cfc4
to
9c79367
Compare
// Allow returning a temporary reference from an async function | ||
case 'then': | ||
// Allow returning a temporary reference from an async function | ||
// Unlike regular Client References, a Promise would never have been serialized as | ||
// an opaque Temporary Reference, but instead would have been serialized as a | ||
// Promise on the server and so doesn't hit this path. So we can assume this wasn't | ||
// a Promise on the client. |
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.
The actual diff is in #33761. This is just about adding an explainer
Fixes #33534.
.then
method can be tested when you await a value that's not a Promise. For regular Client References we have a way to mark those as "async" and yield a reference to the unwrapped value in case it's a Promise on the Client.However, the realization is that we never serialize Promises as opaque when passed from the client to the server. If a Promise is passed, then it would've been deserialized as a Promise (while still registered as a temporary reference) and not one of these Proxy objects.
Technically it could be a non-function value on the client which would be wrong but you're not supposed to dot into it in the first place.
So we can just assume it's
undefined
.