|
| 1 | +import { ApplicationError } from '@n8n/errors'; |
1 | 2 | import { parse as esprimaParse, Syntax } from 'esprima-next';
|
2 | 3 | import type { Node as SyntaxNode, ExpressionStatement } from 'esprima-next';
|
3 | 4 | import FormData from 'form-data';
|
4 | 5 | import merge from 'lodash/merge';
|
5 | 6 |
|
6 | 7 | import { ALPHABET } from './constants';
|
7 |
| -import { ApplicationError } from '@n8n/errors'; |
8 | 8 | import { ExecutionCancelledError } from './errors/execution-cancelled.error';
|
9 | 9 | import type { BinaryFileType, IDisplayOptions, INodeProperties, JsonObject } from './interfaces';
|
| 10 | +import * as LoggerProxy from './logger-proxy'; |
10 | 11 |
|
11 | 12 | const readStreamClasses = new Set(['ReadStream', 'Readable', 'ReadableStream']);
|
12 | 13 |
|
@@ -181,7 +182,18 @@ export const replaceCircularReferences = <T>(value: T, knownObjects = new WeakSe
|
181 | 182 | knownObjects.add(value);
|
182 | 183 | const copy = (Array.isArray(value) ? [] : {}) as T;
|
183 | 184 | for (const key in value) {
|
184 |
| - copy[key] = replaceCircularReferences(value[key], knownObjects); |
| 185 | + try { |
| 186 | + copy[key] = replaceCircularReferences(value[key], knownObjects); |
| 187 | + } catch (error: unknown) { |
| 188 | + if ( |
| 189 | + error instanceof TypeError && |
| 190 | + error.message.includes('Cannot assign to read only property') |
| 191 | + ) { |
| 192 | + LoggerProxy.error('Error while replacing circular references: ' + error.message, { error }); |
| 193 | + continue; // Skip properties that cannot be assigned to (readonly, non-configurable, etc.) |
| 194 | + } |
| 195 | + throw error; |
| 196 | + } |
185 | 197 | }
|
186 | 198 | knownObjects.delete(value);
|
187 | 199 | return copy;
|
|
0 commit comments