Skip to content

Conversation

@OlegIvaniv
Copy link
Contributor

@OlegIvaniv OlegIvaniv commented Apr 20, 2023

This PR addresses two issues related to eventBus subscriptions and the implementation of onBeforeUnload in NodeView.

  1. Unsubscribing from eventBus: There's several instances where eventBus.on was used without properly unsubscribing using eventBus.off, or where eventBus.off was called without an appropriate handler. This PR ensures correct event bus unsubscription to prevent memory leaks.

  2. Modifying onBeforeUnload in NodeView: The previous implementation involved appending the onBeforeUnload handler to the global window object, so it could later be disabled from e2e tests. Instead, we now check if the preventNodeViewBeforeUnload property exists in the window object, and terminate the handler if true.

Github issue / Community forum post (link here to close automatically):

@github-actions
Copy link
Contributor

github-actions bot commented Apr 20, 2023

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching **/*.vue:

  • Used composition API for all new components.
  • Added component or unit tests to cover functionality.

Files matching packages/editor-ui/**/*.vue:

  • Added E2E if adding new features.
  • Used design system tokens (colors, spacings...) where possible.

Files matching packages/editor-ui/src/views/NodeView.vue:

  • Avoided adding code here. Only refactored to make it smaller.

Files matching cypress/e2e/**:

  • Avoided chaining commands more than two or three times (to avoid flakiness because only last one will be retried).
  • Spoofed endpoints that are not critical for the test (to avoid flakiness).
  • Picked most efficient path to start the test (for example skipped account setup and starting at /workflow/new for a canvas test).
  • Avoided adding waits on time (use request intercepts instead).
  • Ensured each spec does not depend on any another spec to pass.

Make sure to check off this list before asking for review.

@OlegIvaniv OlegIvaniv changed the title performance(editor): Fix memory leak in NodeSettings component perf(editor): Fix memory leak in NodeSettings component Apr 20, 2023
@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (71ed1f4) 18.67% compared to head (decb308) 18.67%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6021   +/-   ##
=======================================
  Coverage   18.67%   18.67%           
=======================================
  Files        2582     2582           
  Lines      116479   116476    -3     
  Branches    18178    18177    -1     
=======================================
+ Hits        21751    21752    +1     
+ Misses      94090    94086    -4     
  Partials      638      638           

see 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@n8n-assistant n8n-assistant bot added n8n team Authored by the n8n team ui Enhancement in /editor-ui or /design-system labels Apr 20, 2023
@OlegIvaniv OlegIvaniv changed the title perf(editor): Fix memory leak in NodeSettings component perf(editor): Correctly unsubscribe from event buses Apr 20, 2023
@OlegIvaniv OlegIvaniv changed the title perf(editor): Correctly unsubscribe from event buses perf(editor): Correctly unsubscribe from event buses (no-changelog) Apr 20, 2023
@OlegIvaniv OlegIvaniv requested a review from netroy April 20, 2023 08:03
netroy
netroy previously approved these changes Apr 20, 2023
Copy link
Contributor

@netroy netroy left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@github-actions
Copy link
Contributor

⚠️ Some Cypress E2E specs are failing, please fix them before merging

@cypress
Copy link

cypress bot commented Apr 20, 2023

1 flaky tests on run #524 ↗︎

0 190 0 0 Flakiness 1

Details:

🌳 node_settings_memory_leak 🖥️ base:16.18.1 🤖 oleg 🗃️ e2e/*
Project: n8n Commit: a8467eec88
Status: Passed Duration: 06:33 💡
Started: Apr 20, 2023 9:12 AM Ended: Apr 20, 2023 9:19 AM
Flakiness  cypress/e2e/17-sharing.cy.ts • 1 flaky test

View Output Video

Test Artifacts
Sharing > should have access to W1, W2, as U1 Output Screenshots Video

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@OlegIvaniv OlegIvaniv requested a review from netroy April 20, 2023 09:22
netroy
netroy previously approved these changes Apr 20, 2023
@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@OlegIvaniv OlegIvaniv requested a review from netroy April 20, 2023 09:32
@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

);
cy.window().then(
(win) => {
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

could we augment the typeof win to have preventNodeViewBeforeUnload?: boolean, so we don't need to sprinkle // @ts-ignore in so many places ?

@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

1 similar comment
@github-actions
Copy link
Contributor

✅ All Cypress E2E specs passed

@netroy netroy changed the title perf(editor): Correctly unsubscribe from event buses (no-changelog) fix(editor): Fix memory leak in Node Detail View by correctly unsubscribing from event buses Apr 20, 2023
@netroy netroy merged commit 0970ec0 into master Apr 20, 2023
@netroy netroy deleted the node_settings_memory_leak branch April 20, 2023 10:26
netroy pushed a commit that referenced this pull request Apr 20, 2023
netroy pushed a commit that referenced this pull request Apr 20, 2023
@janober
Copy link
Member

janober commented Apr 20, 2023

Got released with [email protected]

MiloradFilipovic added a commit that referenced this pull request Apr 21, 2023
* master: (199 commits)
  feat(editor): Add disable template experiment (#5963)
  feat(core): Upgrade google-timezones-json to use the correct timezone for Sao Paulo (#6042)
  fix(Code Node): Update vm2 to address CVE-2023-30547 (#6039)
  docs: Add proprietary license text (no-changelog) (#6038)
  test(n8n Node): Unit tests (no-changelog)
  refactor: Accumulate `loadOptions` from all node versions to validate (no-changelog) (#6014)
  Update CHANGELOG.md
  feat: Add variables e2e tests (no-changelog) (#6027)
  fix(editor): Fix typo in SSO upgrade link (#6031)
  fix(editor): Add correct add variable button message when no variables created (no-changelog) (#6028)
  docs: Add api notice to credentials for google sheets nodes (no-changelog) (#6024)
  fix(Notion Node): Update credential test to not require user permissions (#6022)
  fix(editor): Clean up demo and template callouts from workflows page (#6023)
  fix(editor): Fix memory leak in Node Detail View by correctly unsubscribing from event buses (#6021)
  fix(editor): SettingsSidebar should disconnect from push when navigating away (#6025)
  fix(editor): Use fake timers in useDebounce.test.ts to make the test less flaky (no-changelog) (#6029)
  docs: Update the info URL for updating n8n (no-changelog) (#6018)
  fix(core): Improve domain and url matching for extractDomain and extractUrl (#6010)
  feat(core): Add SSH key generation (#6006)
  fix(editor): Update SSO upgrade link (#6016)
  ...

# Conflicts:
#	packages/editor-ui/src/components/WorkflowShareModal.ee.vue
#	packages/editor-ui/src/stores/workflows.ts
#	packages/editor-ui/src/views/NodeView.vue
sunilrr pushed a commit to fl-g6/qp-n8n that referenced this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team Released ui Enhancement in /editor-ui or /design-system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants