mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(core): Avoid using Object.keys on Buffer and other non-plain objects (#6131)
* create a unified way to check if an object is empty * avoid running `Object.keys` on Buffer objects, to avoid unnecessary memory usage
This commit is contained in:
committed by
GitHub
parent
188ef042cd
commit
a3aba835a1
@@ -64,6 +64,7 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
createDeferredPromise,
|
||||
isObjectEmpty,
|
||||
NodeApiError,
|
||||
NodeHelpers,
|
||||
NodeOperationError,
|
||||
@@ -727,10 +728,6 @@ export async function proxyRequestToAxios(
|
||||
}
|
||||
}
|
||||
|
||||
function isIterator(obj: unknown): boolean {
|
||||
return obj instanceof Object && Symbol.iterator in obj;
|
||||
}
|
||||
|
||||
function convertN8nRequestToAxios(n8nRequest: IHttpRequestOptions): AxiosRequestConfig {
|
||||
// Destructure properties with the same name first.
|
||||
const { headers, method, timeout, auth, proxy, url } = n8nRequest;
|
||||
@@ -794,7 +791,7 @@ function convertN8nRequestToAxios(n8nRequest: IHttpRequestOptions): AxiosRequest
|
||||
// if there is a body and it's empty (does not have properties),
|
||||
// make sure not to send anything in it as some services fail when
|
||||
// sending GET request with empty body.
|
||||
if (isIterator(body) || Object.keys(body).length > 0) {
|
||||
if (typeof body === 'object' && !isObjectEmpty(body)) {
|
||||
axiosRequest.data = body;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user