Skip to content
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

HTTP output through context.done(null, res) and $return is not handled correctly #228

Closed
mhoeger opened this issue Jun 24, 2019 · 3 comments

Comments

@mhoeger
Copy link
Contributor

mhoeger commented Jun 24, 2019

Setting HTTP output through context.done(null, res) and http output is not handled correctly.

Example:

let res = {
    status: 200,
    body: ["my", "array", "of", "results"],
    cookies: [ { name: "CookieName", value: "CookieValue" } ]
}
context.done(null, res);

Will return System.Collections.Generic.List`1[System.Object] as the body and not properly set the HTTP cookie.

We can't change this yet because the bugfix is a breaking change. Currently, this behavior is supported (which would break with the bugfix):

let results = ["my", "array", "of", "results"];
context.done(null, results);

Today, this returns a 200 with the HTTP body [ "my", "array", "of", "results" ] when http output binding is named $return

The code fix: In WorkerChannel.ts => invocationRequest => resultCallback => if (result.return), we need to check if it is an HTTP type and not just a generic "TypedData"

The mitigation: do not use context.done(err?, results?) to output results for HTTP output binding.

@mhoeger mhoeger added the 3.x label Aug 14, 2019
wbreza added a commit to serverless/serverless-azure-functions that referenced this issue Sep 5, 2019
This updates the default value for the name of the HTTP output binding from $return to $res to work around an issue that existing within the Azure core tools http runtime..

A bug exists in the Azure core tools http runtime that evaluates $return binding incorrectly which causes serialization issues when returning arrays within an HTTP response.
Azure/azure-functions-nodejs-worker#228
tbarlow12 pushed a commit to serverless/serverless-azure-functions that referenced this issue Sep 13, 2019
This updates the default value for the name of the HTTP output binding from $return to $res to work around an issue that existing within the Azure core tools http runtime..

A bug exists in the Azure core tools http runtime that evaluates $return binding incorrectly which causes serialization issues when returning arrays within an HTTP response.
Azure/azure-functions-nodejs-worker#228
@fabiocav fabiocav added this to the Triaged milestone Oct 11, 2019
mhoeger added a commit to mhoeger/azure-functions-nodejs-worker that referenced this issue Nov 19, 2019
This was referenced Nov 19, 2019
@mhoeger mhoeger modified the milestones: Triaged, Functions Sprint 64 Dec 4, 2019
@mhoeger mhoeger closed this as completed Dec 4, 2019
@dhensby
Copy link

dhensby commented Dec 4, 2019

What version of functions is this fix available in?

@mhoeger
Copy link
Contributor Author

mhoeger commented Dec 4, 2019

Functions V3 (https://github.com/Azure/azure-functions-host/releases/tag/3.0.12915). This is still a preview version of Functions, but we're targeting to get it out of preview by end of year!

@dhensby
Copy link

dhensby commented Dec 10, 2019

thanks

mhoeger added a commit to mhoeger/azure-functions-nodejs-worker that referenced this issue Jan 14, 2020
mhoeger added a commit that referenced this issue Jan 15, 2020
@mhoeger mhoeger changed the title HTTP output through context.done(null, res) is not handled correctly HTTP output through context.done(null, res) and $return is not handled correctly Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants