This differential solves bug that is well described in relevant Linear task:
https://linear.app/comm/issue/ENG-5890/macos-app-looses-devicetoken-in-undeterministic-manner
Details
Details
Build desktop app. Log in and log out multiple time. Ensure that notifications are always working. Additionally close and re-open the window (without closing app!). Ensure that no error appears in console and notifications work correctly.
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
desktop/src/main.js | ||
---|---|---|
263 ↗ | (On Diff #33595) | Can you just pass sendDeviceTokenToWebApp directly? If there's a Flow issue, then I suspect the type for ipcMain.on should be updated to accept any return value (mixed) instead of insisting on void |
Comment Actions
There are a few issues with this (but they should be easily fixable):
- You are registering a callback on ipcMain everytime a window is loaded. This wouldn't be a problem in Windows but on macOS you can close the window without closing the app. Then if you would open a window again you would register another callback.
- The callbacks themselves use the main window variable which will stop being valid after the window is closed. So the previously registered callbacks will probably throw an error after re-opening the window.
We probably want to:
- Make the sendDeviceTokenToWebApp function a global function that uses the mainWindow variable which should always point at the current window (or be null)
- Call ipcMain.on only once (near the other calls to it)
Could you amend the test plan with closing and re-opening the window (on macOS, without closing the whole app) and checking if there are no errors?