Explicitly serialize output properties in closures

This commit is contained in:
joeduffy 2017-09-06 14:51:00 -07:00
parent aefe297aa1
commit 93743733fb
2 changed files with 5 additions and 0 deletions

View file

@ -97,6 +97,10 @@ async function serializeCapturedObject(obj: any): Promise<EnvironmentEntry> {
// If this is a promise, we will await it and serialize the result instead.
return serializeCapturedObject(await obj);
}
else if (obj instanceof Property) {
// If this is a property, explicitly await its output promise so that we get the raw value.
return serializeCapturedObject(await obj.outputPromise);
}
else if ((obj as Computed<any>).mapValue) {
// If this is a computed value -- including a captured fabric resource property -- mapValue it.
return await new Promise<EnvironmentEntry>((resolve) => {

View file

@ -37,6 +37,7 @@ export function registerResource(
// Fetch the monitor; if it doesn't exist, bail right away.
if (!monitor) {
Log.debug(`Not sending RPC to monitor -- it doesn't exist: t=${t}, name=${name}`);
return;
}