mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Account for readonly properties when replacing circular references (#18408)
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { parse as esprimaParse, Syntax } from 'esprima-next';
|
||||
import type { Node as SyntaxNode, ExpressionStatement } from 'esprima-next';
|
||||
import FormData from 'form-data';
|
||||
import merge from 'lodash/merge';
|
||||
|
||||
import { ALPHABET } from './constants';
|
||||
import { ApplicationError } from '@n8n/errors';
|
||||
import { ExecutionCancelledError } from './errors/execution-cancelled.error';
|
||||
import type { BinaryFileType, IDisplayOptions, INodeProperties, JsonObject } from './interfaces';
|
||||
import * as LoggerProxy from './logger-proxy';
|
||||
|
||||
const readStreamClasses = new Set(['ReadStream', 'Readable', 'ReadableStream']);
|
||||
|
||||
@@ -181,7 +182,18 @@ export const replaceCircularReferences = <T>(value: T, knownObjects = new WeakSe
|
||||
knownObjects.add(value);
|
||||
const copy = (Array.isArray(value) ? [] : {}) as T;
|
||||
for (const key in value) {
|
||||
copy[key] = replaceCircularReferences(value[key], knownObjects);
|
||||
try {
|
||||
copy[key] = replaceCircularReferences(value[key], knownObjects);
|
||||
} catch (error: unknown) {
|
||||
if (
|
||||
error instanceof TypeError &&
|
||||
error.message.includes('Cannot assign to read only property')
|
||||
) {
|
||||
LoggerProxy.error('Error while replacing circular references: ' + error.message, { error });
|
||||
continue; // Skip properties that cannot be assigned to (readonly, non-configurable, etc.)
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
knownObjects.delete(value);
|
||||
return copy;
|
||||
|
||||
Reference in New Issue
Block a user