Hi there,
I’m creating a respondToWebhook node with a streaming response option, but can’t figure out how to control the response header to put Content-Type: text/event-stream
, My use case would be to get a steaming response from the previous node and return it to the webhook client and keep responding as long as the streaming is not closed.
Inspired by the HTTP request node, I wanted to return an array of responses with the header 'Content-Type': 'text/event-stream'
but the response is considered as JSON body with no consideration of the headers put.
// For testing I'm just getting chunks of strings
let returnItems: INodeExecutionData[] = [];
for (const chunk of chunks) {
returnItems.push({
json: {
headers: {
'Content-Type': 'text/event-stream',
},
body: {
eventType: 'update',
data: {
message: chunk,
timestamp: new Date().toISOString(),
},
},
},
});
}
return [returnItems];
also, the sendResponse
function is not returning nothing at all:
for (const chunk of chunks) {
this.sendResponse({
json: {
headers: {
'Content-Type': 'text/event-stream',
},
body: {
eventType: 'update',
data: {
message: chunk,
timestamp: new Date().toISOString(),
},
},
},
});
Am I missing something here?