diff --git a/sdk/nodejs/runtime/property.ts b/sdk/nodejs/runtime/property.ts index f495081db..31932bda4 100644 --- a/sdk/nodejs/runtime/property.ts +++ b/sdk/nodejs/runtime/property.ts @@ -66,30 +66,26 @@ export class Property implements Computed { else { try { // There's a callback; invoke it. - let u: MaybeComputed | undefined; try { mapValueCallbackRecursionCount++; - u = callback(value); + + let u: MaybeComputed = callback(value); + // If this is another computed, we need to wire up to its resolution; else just store the value. + if (u && u instanceof Promise) { + u.then((v: U) => { result.setOutput(v, true, false); }); + } + else if (u && (u as Computed).mapValue) { + (u as Computed).mapValue((v: U) => { + result.setOutput(v, true, false); + }); + } + else { + result.setOutput(u, true, false); + } } finally { mapValueCallbackRecursionCount--; } - if (u === undefined) { - throw new Error("MapValue yielded no result"); - } - - // If this is another computed, we need to wire up to its resolution; else just store the value. - if (u instanceof Promise) { - u.then((v: U) => { result.setOutput(v, true, false); }); - } - else if ((u as Computed).mapValue) { - (u as Computed).mapValue((v: U) => { - result.setOutput(v, true, false); - }); - } - else { - result.setOutput(u, true, false); - } } catch (err) { Log.error(`MapValue of a Computed yielded an unhandled error: ${err}`);