electron: [Bug]: notification.close() does not work in Windows after the popup has disappeared
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Electron Version
16.0.4
What operating system are you using?
Windows
Operating System Version
Windows 11 21H2 22000.376
What arch are you using?
x64
Last Known Working Electron version
No response
Expected Behavior
Repro:
- Create a notification in the renderer process with the HTML5 notification API
- Wait for the notification popup to disappear and be logged to the Windows notification center
- Call
notification.close()
on it
The notification is removed from the Windows notification center and the “unread” count in the taskbar decreases
Actual Behavior
The notification remains in the Windows notification center and the unread count does not change.
Testcase Gist URL
https://gist.github.com/eeba5a0f434736fe3a58966e74fce37d
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 15 (2 by maintainers)
Out of sight, out of mind, eh? An issue become not an issue if you wait long enough?
As a work around I’m adding 6 sec delay and forcibly close the notification: in main process
or in renderer:
(only tested on Windows 10)
P.S. Electron
v20.0.0-nightly.20220330
still affected.Windows 11 also affected. The last working version was v11.5.0; Starting with v12.0.0beta1 the notifications become “persistent”.
In addition, clicking at the notification in the notification center clears the notification, however
onclick
event never fired/received and after reopening notification center the notification shown again. The only way get rid of it is to clickx
The issue affects both native HTML5 notifications and electron’s
Notification
There are two sides:
I won’t be trying to figure out part 2 here; I’m currently focusing on migrating to Tauri.
Hi, is there any plan to fix this issue? Or, somebody know any alternative plan?
I wonder if this bug related to bundled chromium version and not electron itself?
Do you have any plan to resolve the issue?
Looking at the spec more closely: https://notifications.spec.whatwg.org/#lifetime-and-ui-integrations
It seems like right now Electron is doing a cross between persistent and non-persistent here. It is firing the
close
event on the notification as soon as the popup disappears but is leaving an entry in the notification center as a piece of trash if the user doesn’t get to it right away.