mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -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
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||||
const value = Reflect.get(target, key, receiver);
|
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);
|
const newValue = augment(value);
|
||||||
if (newValue !== value) {
|
if (newValue !== value) {
|
||||||
Object.assign(newData, { [key]: newValue });
|
Object.assign(newData, { [key]: newValue });
|
||||||
|
|
|
@ -233,8 +233,8 @@ describe('AugmentObject', () => {
|
||||||
a: 9111,
|
a: 9111,
|
||||||
b: '9222',
|
b: '9222',
|
||||||
c: 3,
|
c: 3,
|
||||||
d: date,
|
d: date.toJSON(),
|
||||||
r: regexp,
|
r: regexp.toString(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue