Return of void does not work for node function
Function template: void Language: node
There is possible return types in the docs https://github.com/knative/func/tree/main/templates/node/cloudevents#handle-signature:
type CloudEventFunctionReturn = Promise<CloudEvent> | CloudEvent | HTTPFunctionReturn;
type HTTPFunctionReturn = Promise<StructuredReturn> | StructuredReturn | ResponseBody | void;
When I try to return nothing:
const handle = async (context, event) => {
// YOUR CODE HERE
context.log.info("context", context);
context.log.info("event", event);
};
I get error
curl -X POST -d '{"name": "Tiger", "customerId": "0123456789"}' \
-H'Content-type: application/json' \
-H'Ce-id: 1' \
-H'Ce-source: cloud-event-example' \
-H'Ce-type: dev.knative.example' \
-H'Ce-specversion: 1.0' \
http://localhost:8080
Cannot read properties of undefined (reading 'constructor')
How do I return void?
Hello @astelmashenko,
Our Node.js middleware is under active development, and unfortunately that has resulted in a few of our return types being only partially implemented.
An updated version of the Node.js middleware is in progress, but for the short term I would recommend returning an empty StructuredReturn or ResponseBody in leau of a proper void.
We can leave this issue open to ensure that the upcoming middleware release tests the void return is working correctly.
Thanks for opening the issue, and sorry for the inconvenience
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.
/remove-lifecycle stale
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.
/remove-lifecycle stale
This issue is stale because it has been open for 90 days with no
activity. It will automatically close after 30 more days of
inactivity. Reopen the issue with /reopen. Mark the issue as
fresh by adding the comment /remove-lifecycle stale.