fix(core): Serialize BigInts (#6805)

* workaround for non-serializable BigInt

* refactor
This commit is contained in:
Michael Auerswald 2023-07-31 16:53:30 +02:00 committed by GitHub
parent 651cf34da6
commit 7b27fa5898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -12,3 +12,7 @@ declare module '@n8n_io/riot-tmpl' {
let brackets: Brackets;
let tmpl: Tmpl;
}
interface BigInt {
toJSON(): string;
}

View file

@ -3,6 +3,12 @@ import type { BinaryFileType, JsonObject } from './Interfaces';
const readStreamClasses = new Set(['ReadStream', 'Readable', 'ReadableStream']);
// NOTE: BigInt.prototype.toJSON is not available, which causes JSON.stringify to throw an error
// as well as the flatted stringify method. This is a workaround for that.
BigInt.prototype.toJSON = function () {
return this.toString();
};
export const isObjectEmpty = (obj: object | null | undefined): boolean => {
if (obj === undefined || obj === null) return true;
if (typeof obj === 'object') {