async getResponse()

in src/InvocationModel.ts [113:145]


    async getResponse(context: InvocationContext, result: unknown): Promise<RpcInvocationResponse> {
        const response: RpcInvocationResponse = { invocationId: this.#coreCtx.invocationId };

        response.outputData = [];
        let usedReturnValue = false;
        for (const [name, binding] of Object.entries(this.#bindings)) {
            if (binding.direction === 'out') {
                if (name === returnBindingKey) {
                    response.returnValue = await this.#convertOutput(context.invocationId, binding, result);
                    usedReturnValue = true;
                } else {
                    const outputValue = await this.#convertOutput(
                        context.invocationId,
                        binding,
                        context.extraOutputs.get(name)
                    );
                    if (isDefined(outputValue)) {
                        response.outputData.push({ name, data: outputValue });
                    }
                }
            }
        }

        // This allows the return value of non-HTTP triggered functions to be passed back
        // to the host, even if no explicit output binding is set. In most cases, this is ignored,
        // but e.g., Durable uses this to pass orchestrator state back to the Durable extension, w/o
        // an explicit output binding. See here for more details: https://github.com/Azure/azure-functions-nodejs-library/pull/25
        if (!usedReturnValue && !isHttpTrigger(this.#triggerType)) {
            response.returnValue = toRpcTypedData(result);
        }

        return response;
    }