Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function CreateContextAndInputs(info: FunctionInfo, request: rpc.IInvocat
if (httpInput) {
context.req = new Request(httpInput);
context.res = new Response(context.done);
// This is added for backwards compatability with what the host used to send to the worker
// This is added for backwards compatibility with what the host used to send to the worker
context.bindingData.sys = {
methodName: info.name,
utcNow: (new Date()).toISOString(),
Expand Down
4 changes: 2 additions & 2 deletions src/WorkerChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ export class WorkerChannel implements IWorkerChannel {
response.outputData = [];

try {
if (result) {
if (result != null) {
let returnBinding = info.getReturnBinding();
// Set results from return / context.done
if (result.return) {
if (result.return != null) {
if (this._v1WorkerBehavior) {
response.returnValue = toTypedData(result.return);
} else {
Expand Down
39 changes: 39 additions & 0 deletions test/WorkerChannelTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,45 @@ describe('WorkerChannel', () => {
assertInvocationSuccess(expectedOutput, expectedReturnValue);
});

it ('returns and serializes falsy value: ""', () => {
loader.getFunc.returns((context) => context.done(null, ""));
loader.getInfo.returns(new FunctionInfo(orchestratorBinding));

sendInvokeMessage([], getHttpTriggerDataMock());

const expectedOutput = [];
const expectedReturnValue = {
string: ""
};
assertInvocationSuccess(expectedOutput, expectedReturnValue);
});

it ('returns and serializes falsy value: 0', () => {
loader.getFunc.returns((context) => context.done(null, 0));
loader.getInfo.returns(new FunctionInfo(orchestratorBinding));

sendInvokeMessage([], getHttpTriggerDataMock());

const expectedOutput = [];
const expectedReturnValue = {
int: 0
};
assertInvocationSuccess(expectedOutput, expectedReturnValue);
});

it ('returns and serializes falsy value: false', () => {
loader.getFunc.returns((context) => context.done(null, false));
loader.getInfo.returns(new FunctionInfo(orchestratorBinding));

sendInvokeMessage([], getHttpTriggerDataMock());

const expectedOutput = [];
const expectedReturnValue = {
json: "false"
};
assertInvocationSuccess(expectedOutput, expectedReturnValue)
});

it ('returned output is ignored if http', () => {
loader.getFunc.returns((context) => context.done(null, ["hello, seattle!", "hello, tokyo!"]));
loader.getInfo.returns(new FunctionInfo(httpResBinding));
Expand Down