-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): make deepCopy
backward compatible
#4505
Conversation
`JSON.parse(JSON.stringify())` uses `.toJSON` when available. so should `deepCopy`
* 🐛 Prevent double quotes on luxon datetimes * ⚡ Generalize solution
773948e
to
b0e2b18
Compare
…` on objects that have it
with LGTM. Please approve and merge at will. |
packages/workflow/src/utils.ts
Outdated
@@ -28,7 +28,7 @@ export const deepCopy = <T extends ((object | Date) & { toJSON?: () => string }) | |||
return clone as T; | |||
} | |||
// Object | |||
const clone = {} as T; | |||
const clone = Object.create(Object.getPrototypeOf(source)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might have the same issue here: the change makes semantic sense, but since we did not include the prototype in the cloned objects before, it's hard to know what side-effects this addition would have.
Can you please remove this?
we should definitely do this, just not in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works with Object.create(null)
as well and passing the tests but in my perf testing it fails and works only with Object.create(Object.getPrototypeOf(source))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's just assert.deepStrictEqual
in nodejs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this works in both places Object.create(Object.getPrototypeOf({}));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
// Object | ||
clone = {}; | ||
const clone = Object.create(Object.getPrototypeOf({})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't Object.create(Object.getPrototypeOf({}))
same as {}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably, but with the object literal we ran into type issues again
Got released with |
* master: refactor(editor): Migrate part of the vuex store to pinia (#4484) fix(editor): fix themes the monaco editor (no-changelog) (#4521) refactor(editor): restrict mapping discoverability tooltip showing only on string input (#4496) 📚 Remove entries from Changelog 📚 Update CHANGELOG.md and main package.json to 0.201.0 🔖 Release [email protected] ⬆️ Set [email protected], [email protected], [email protected] and [email protected] on n8n 🔖 Release [email protected] ⬆️ Set [email protected] and [email protected] on n8n-editor-ui 🔖 Release [email protected] 🔖 Release [email protected] ⬆️ Set [email protected] and [email protected] on n8n-nodes-base 🔖 Release [email protected] ⬆️ Set [email protected] and [email protected] on n8n-node-dev 🔖 Release [email protected] ⬆️ Set [email protected] on n8n-core 🔖 Release [email protected] fix(core): make `deepCopy` backward compatible (#4505) fix(editor): workflow settings link font size change (no-changelog) (#4511) perf(editor): improve array intersection utility function (#4503) # Conflicts: # packages/editor-ui/src/App.vue # packages/editor-ui/src/components/ActivationModal.vue # packages/editor-ui/src/components/NDVDraggablePanels.vue # packages/editor-ui/src/components/NodeSettings.vue # packages/editor-ui/src/components/Sticky.vue # packages/editor-ui/src/components/mixins/workflowHelpers.ts # packages/editor-ui/src/constants.ts # packages/editor-ui/src/plugins/i18n/index.ts # packages/editor-ui/src/views/ChangePasswordView.vue # packages/editor-ui/src/views/NodeView.vue # packages/editor-ui/src/views/SignupView.vue
JSON.parse(JSON.stringify())
uses.toJSON
when available. so shoulddeepCopy