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:
कारतोफ्फेलस्क्रिप्ट™
2023-04-28 11:05:48 +00:00
committed by GitHub
parent 188ef042cd
commit a3aba835a1
5 changed files with 101 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ import type {
IHttpRequestOptions,
INodeProperties,
} from 'n8n-workflow';
import { isObjectEmpty } from 'n8n-workflow';
import type { OptionsWithUri } from 'request';
export const regions = [
@@ -353,7 +354,7 @@ export class Aws implements ICredentialType {
});
}
if (body && Object.keys(body).length === 0) {
if (body && typeof body === 'object' && !isObjectEmpty(body)) {
body = '';
}