n8n - ✅(Solved) Fix Core Refactor: deepCopy utility improperly serializes Date objects to strings (resolves legacy TODO) [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#29201Fetched 2026-04-28 06:49:28
View on GitHub
Comments
1
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1mentioned ×1

Fix Action

Fixed

PR fix notes

PR #29203: refactor(core): fix deepCopy Date serialization and resolve legacy TODO

Description (problem / solution / changelog)

Summary

This PR resolves a long-standing technical debt TODO inside the core deepCopy utility (packages/workflow/src/utils.ts).

What it does: Previously, deepCopy intercepted any object with a .toJSON() method (most notably Date objects) and serialized them into strings instead of properly cloning them. This PR refactors the function to properly instantiate isolated Date clones and removes the .toJSON() catch-all trap entirely.

How to test: Run the workflow package test suite locally to verify the new deep clone logic: pnpm --filter n8n-workflow test

Legacy tests in utils.test.ts and augment-object.test.ts that were previously hardcoded to expect the stringification bug have been updated to assert for true deep equality and reference isolation. All 4,214 tests pass locally.

Related Linear tickets, Github issues, and Community forum posts

Fixes #29201

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

Changed files

  • packages/workflow/src/utils.ts (modified, +6/-3)
  • packages/workflow/test/augment-object.test.ts (modified, +1/-1)
  • packages/workflow/test/utils.test.ts (modified, +6/-3)
RAW_BUFFERClick to expand / collapse

Bug Description

Issue Body:

Describe the bug The core deepCopy utility located in packages/workflow/src/utils.ts contains a legacy TODO that traps objects with a .toJSON() method. Currently, if a Date object is passed into deepCopy, the utility calls .toJSON() and returns an ISO string instead of returning a cloned Date object.

This creates hidden technical debt, as downstream nodes and tests relying on deepCopy expect strings instead of preserving the original Date types.

Additional context

I have already developed a fix for this that replaces the .toJSON() trap with proper Date instantiation. I have also updated the legacy tests in utils.test.ts and augment-object.test.ts that were hardcoded to expect the stringification bug, and the full monorepo test suite is passing locally. I will link a PR to this issue shortly!

To Reproduce

Pass a Javascript Date object into the deepCopy utility from n8n-workflow.

Observe that the returned value is a string (e.g., "2026-04-27T00:00:00.000Z") rather than an independent Date instance.

Expected behavior

Pass a Javascript Date object into the deepCopy utility from n8n-workflow.

Observe that the returned value is a string (e.g., "2026-04-27T00:00:00.000Z") rather than an independent Date instance.

Debug Info

The core deepCopy utility located in packages/workflow/src/utils.ts contains a legacy TODO that traps objects with a .toJSON() method. Currently, if a Date object is passed into deepCopy, the utility calls .toJSON() and returns an ISO string instead of returning a cloned Date object.

This creates hidden technical debt, as downstream nodes and tests relying on deepCopy expect strings instead of preserving the original Date types.

Operating System

windows 11

n8n Version

2.17.3

Node.js Version

22.16.0

Database

SQLite (default)

Execution mode

main (default)

Hosting

self hosted

extent analysis

TL;DR

The deepCopy utility should be updated to properly clone Date objects instead of converting them to ISO strings using the toJSON() method.

Guidance

  • Review the fix developed for this issue, which replaces the .toJSON() trap with proper Date instantiation, to understand the necessary changes.
  • Verify that the updated deepCopy utility correctly clones Date objects by passing a Date object into the utility and checking the returned value is an independent Date instance.
  • Check the updated tests in utils.test.ts and augment-object.test.ts to ensure they are no longer hardcoded to expect the stringification bug.
  • Wait for the PR to be linked to this issue to review the exact changes and implementation.

Example

No code example is provided as the issue does not contain the exact implementation details of the fix.

Notes

The provided information suggests that a fix has already been developed, and the full monorepo test suite is passing locally. However, it's essential to review the PR and verify the changes to ensure the issue is fully resolved.

Recommendation

Apply the workaround by updating the deepCopy utility with the developed fix, as it correctly addresses the issue and preserves the original Date types.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Pass a Javascript Date object into the deepCopy utility from n8n-workflow.

Observe that the returned value is a string (e.g., "2026-04-27T00:00:00.000Z") rather than an independent Date instance.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING