mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(core): Serialize dates and regexps when reading from augmented objects (#6086)
https://community.n8n.io/t/workflows-fail-when-triggered-but-succeed-when-run-manually/25575
This commit is contained in:
parent
390841bbf0
commit
a4eb46acc1
|
@ -90,6 +90,11 @@ export function augmentObject<T extends object>(data: T): T {
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const value = Reflect.get(target, key, receiver);
|
||||
|
||||
if (typeof value !== 'object' || value === null) return value;
|
||||
if (value instanceof RegExp) return value.toString();
|
||||
if ('toJSON' in value && typeof value.toJSON === 'function') return value.toJSON() as T;
|
||||
|
||||
const newValue = augment(value);
|
||||
if (newValue !== value) {
|
||||
Object.assign(newData, { [key]: newValue });
|
||||
|
|
|
@ -233,8 +233,8 @@ describe('AugmentObject', () => {
|
|||
a: 9111,
|
||||
b: '9222',
|
||||
c: 3,
|
||||
d: date,
|
||||
r: regexp,
|
||||
d: date.toJSON(),
|
||||
r: regexp.toString(),
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue