From c86cd114d7013fc56ea1c9eefd9f23b4852c405e Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 9 Mar 2023 17:12:01 +0100 Subject: [PATCH 1/3] Add fix for trying to pipe non streams --- packages/core/src/NodeExecuteFunctions.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 6186c873362eb..80539546f3576 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -99,7 +99,7 @@ import type { } from 'axios'; import axios from 'axios'; import url, { URL, URLSearchParams } from 'url'; -import type { Readable } from 'stream'; +import { Readable } from 'stream'; import { access as fsAccess } from 'fs/promises'; import { createReadStream } from 'fs'; @@ -687,7 +687,12 @@ async function proxyRequestToAxios( if (response) { Logger.debug('Request proxied to Axios failed', { status: response.status }); let responseData = response.data; - responseData = await binaryToBuffer(responseData); + + if (Buffer.isBuffer(responseData)) { + responseData = responseData.toString('utf-8'); + } else if (responseData instanceof Readable) { + responseData = await binaryToBuffer(responseData); + } error.message = `${response.status as number} - ${JSON.stringify(responseData)}`; } From 997022478ff39edc5b5e5a1af5448172f9436224 Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 9 Mar 2023 17:16:40 +0100 Subject: [PATCH 2/3] Stringify result --- packages/core/src/NodeExecuteFunctions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 80539546f3576..766f205dccc62 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -691,7 +691,9 @@ async function proxyRequestToAxios( if (Buffer.isBuffer(responseData)) { responseData = responseData.toString('utf-8'); } else if (responseData instanceof Readable) { - responseData = await binaryToBuffer(responseData); + responseData = await binaryToBuffer(responseData).then((buffer) => + buffer.toString('utf-8'), + ); } error.message = `${response.status as number} - ${JSON.stringify(responseData)}`; } From 4be199cc2c8895253b91b4e61c09de56ff6b38ea Mon Sep 17 00:00:00 2001 From: agobrech Date: Thu, 9 Mar 2023 17:23:27 +0100 Subject: [PATCH 3/3] Simplify checkk for object streamable --- packages/core/src/NodeExecuteFunctions.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 766f205dccc62..0e1d88876d26b 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -688,9 +688,7 @@ async function proxyRequestToAxios( Logger.debug('Request proxied to Axios failed', { status: response.status }); let responseData = response.data; - if (Buffer.isBuffer(responseData)) { - responseData = responseData.toString('utf-8'); - } else if (responseData instanceof Readable) { + if (Buffer.isBuffer(responseData) || responseData instanceof Readable) { responseData = await binaryToBuffer(responseData).then((buffer) => buffer.toString('utf-8'), );