Skip to content

fix: prevent garbage collection of notification objects and ensure proper initialization order#1622

Merged
ShGKme merged 2 commits intonextcloud:mainfrom
kikoso:fix/1621/notification-click-fix
Jan 20, 2026
Merged

fix: prevent garbage collection of notification objects and ensure proper initialization order#1622
ShGKme merged 2 commits intonextcloud:mainfrom
kikoso:fix/1621/notification-click-fix

Conversation

@kikoso
Copy link
Copy Markdown
Contributor

@kikoso kikoso commented Jan 10, 2026

☑️ Resolves

🖼️ Screenshots

📝 Description

This PR fixes the issue where clicking on the "New version available" notification did nothing.

The root cause was identified as the Notification object being garbage collected by Electron's main process before the user could interact with it. Additionally, the notification scheduler was starting before the app was fully ready.

Changes:

  • Persistent Notifications: Introduced a Set to hold references to Notification objects in githubReleaseNotification.service.js and downloads.ts, preventing garbage collection until they are closed or clicked.
  • Improved Initialization: Moved the update check scheduler inside app.whenReady() in main.js.
  • Standardized URL: Updated the release URL format to use the standardized /tag/ prefix.
🏚️ Before 🏡 After
Clicking the update notification does nothing Clicking the notification opens the GitHub release page correctly

Copy link
Copy Markdown
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!
Indeed, they are garbage collected...

Just some small comment, and we can have it in ☺️

Comment on lines +99 to +101
notification.on('close', () => {
notifications.delete(notification!)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing I'm worried about is that the close event is not guaranteed to be fired, which may lead to a small memory leak... But after checking a number of Electron issues, I don't see any better solution =\

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Set is used to prevent the Notification object from being garbage collected by Electron's main process while the OS is still displaying it. This is a known behavior where if no JavaScript reference is kept, the click event listeners are destroyed before they can be triggered. I am not sure if there is a better solution, either - but Download notifications are infrequent, so I guess this will not kill the app through memory leaks.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The current solution prevents notification object from being garbage collected.
But it keeps it in the memory forever (there is no guarantee for the close event).

So in some cases notification object will live in the app memory until restart.

Copy link
Copy Markdown
Contributor

@ShGKme ShGKme Jan 20, 2026

Choose a reason for hiding this comment

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

Though, it seems there is no solution for this problem in Electron =\

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We will go with a better solution for update notifications from another contribution:

Could you revert the changes here, keeping only the /tag/?
Just to remove a conflict between PRs, since this code is to be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've reverted the changes in src/app/githubReleaseNotification.service.js, keeping only the /tag/ fix in the URL as requested. This should resolve the overlap with PR #1592.

@kikoso kikoso marked this pull request as ready for review January 13, 2026 11:05
kikoso added a commit to kikoso/talk-desktop that referenced this pull request Jan 20, 2026
…oper initialization order

- Added a persistent Set to store Notification objects in githubReleaseNotification.service.js and downloads.ts to prevent them from being garbage collected before user interaction.
- Moved setupReleaseNotificationScheduler inside app.whenReady() in main.js to ensure the app is fully initialized before showing notifications.
- Updated GitHub release URL format to use /tag/ prefix for better reliability.

Resolves: nextcloud#1621
Signed-off-by: Enrique López Mañas <eenriquelopez@gmail.com>
Signed-off-by: Enrique López Mañas <eenriquelopez@gmail.com>
@kikoso kikoso force-pushed the fix/1621/notification-click-fix branch from a800be4 to ab315f6 Compare January 20, 2026 17:50
@kikoso
Copy link
Copy Markdown
Contributor Author

kikoso commented Jan 20, 2026

@ShGKme , rebased and committed to fix the DCO.

Copy link
Copy Markdown
Contributor

@ShGKme ShGKme left a comment

Choose a reason for hiding this comment

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

Thank you!

@ShGKme ShGKme merged commit 08f11c2 into nextcloud:main Jan 20, 2026
11 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feedback-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updates about notifications are not opening

2 participants