diff --git a/packages/workflow/src/types.d.ts b/packages/workflow/src/types.d.ts index 85bfad7a58..12fdaa8b19 100644 --- a/packages/workflow/src/types.d.ts +++ b/packages/workflow/src/types.d.ts @@ -12,3 +12,7 @@ declare module '@n8n_io/riot-tmpl' { let brackets: Brackets; let tmpl: Tmpl; } + +interface BigInt { + toJSON(): string; +} diff --git a/packages/workflow/src/utils.ts b/packages/workflow/src/utils.ts index 62eed4250f..27d96b4dcb 100644 --- a/packages/workflow/src/utils.ts +++ b/packages/workflow/src/utils.ts @@ -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') {