Skip to content
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

Merged
merged 12 commits into from
Nov 2, 2022

Conversation

netroy
Copy link
Member

@netroy netroy commented Nov 2, 2022

JSON.parse(JSON.stringify()) uses .toJSON when available. so should deepCopy

`JSON.parse(JSON.stringify())`  uses `.toJSON` when available. so should `deepCopy`
@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Nov 2, 2022
packages/workflow/src/utils.ts Outdated Show resolved Hide resolved
packages/workflow/src/utils.ts Outdated Show resolved Hide resolved
@netroy netroy force-pushed the backward-compatible-deepcopy branch from 773948e to b0e2b18 Compare November 2, 2022 12:50
packages/workflow/src/utils.ts Outdated Show resolved Hide resolved
packages/workflow/src/utils.ts Outdated Show resolved Hide resolved
packages/workflow/src/utils.ts Outdated Show resolved Hide resolved
cstuncsik
cstuncsik previously approved these changes Nov 2, 2022
@netroy
Copy link
Member Author

netroy commented Nov 2, 2022

with JSON.parse(JSON.stringify()), we were cloning functions as undefined. Let's hope that isn't going to cause any any issues. 🤞🏽

LGTM. Please approve and merge at will.
And thanks for taking over and wrapping the PR up.

packages/workflow/src/utils.ts Outdated Show resolved Hide resolved
@@ -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));
Copy link
Member Author

@netroy netroy Nov 2, 2022

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.

Copy link
Contributor

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))

Copy link
Contributor

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

Copy link
Contributor

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({}));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it is just around 4% slower and still at the second place according to my perf test
image

cstuncsik
cstuncsik previously approved these changes Nov 2, 2022
@cstuncsik cstuncsik merged commit b282c7e into master Nov 2, 2022
@cstuncsik cstuncsik deleted the backward-compatible-deepcopy branch November 2, 2022 16:44
@n8n-assistant n8n-assistant bot added the Upcoming Release Will be part of the upcoming release label Nov 2, 2022
}
// Object
clone = {};
const clone = Object.create(Object.getPrototypeOf({}));
Copy link
Member Author

@netroy netroy Nov 2, 2022

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 {}?

Copy link
Contributor

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

@janober
Copy link
Member

janober commented Nov 2, 2022

Got released with n8n@0.201.0

@janober janober removed the Upcoming Release Will be part of the upcoming release label Nov 2, 2022
MiloradFilipovic added a commit that referenced this pull request Nov 4, 2022
* 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 n8n@0.201.0
  ⬆️ Set n8n-core@0.141.0, n8n-editor-ui@0.167.0, n8n-nodes-base@0.199.0 and n8n-workflow@0.123.0 on n8n
  🔖 Release n8n-editor-ui@0.167.0
  ⬆️ Set n8n-design-system@0.41.0 and n8n-workflow@0.123.0 on n8n-editor-ui
  🔖 Release n8n-design-system@0.41.0
  🔖 Release n8n-nodes-base@0.199.0
  ⬆️ Set n8n-core@0.141.0 and n8n-workflow@0.123.0 on n8n-nodes-base
  🔖 Release n8n-node-dev@0.80.0
  ⬆️ Set n8n-core@0.141.0 and n8n-workflow@0.123.0 on n8n-node-dev
  🔖 Release n8n-core@0.141.0
  ⬆️ Set n8n-workflow@0.123.0 on n8n-core
  🔖 Release n8n-workflow@0.123.0
  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
netroy added a commit that referenced this pull request Nov 7, 2022
RicardoE105 pushed a commit that referenced this pull request Nov 7, 2022
fix (HTTP Request node): show error cause in the output

This broke in these two PRs

#4505
#4431
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants