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

PUSH_RECEIVER:::Error while starting the service TypeError: Object has been destroyed #70

Open
calvinckho opened this issue Jul 8, 2020 · 1 comment

Comments

@calvinckho
Copy link

calvinckho commented Jul 8, 2020

Here is my setup.

"dependencies": {
"@capacitor/electron": "2.2.1",
"electron-push-receiver": "^2.1.3",
"electron-updater": "^4.3.1",
},
"devDependencies": {
"electron": "9.1.0",
"electron-builder": "22.7.0"
},

in the renderer process:

import {
    START_NOTIFICATION_SERVICE,
    NOTIFICATION_SERVICE_STARTED,
    NOTIFICATION_SERVICE_ERROR,
    NOTIFICATION_RECEIVED as ON_NOTIFICATION_RECEIVED,
    TOKEN_UPDATED,
} from 'electron-push-receiver/src/constants';

// Listen for service successfully started
ipcRenderer.on(NOTIFICATION_SERVICE_STARTED, (_, token) => // do something);
// Handle notification errors
ipcRenderer.on(NOTIFICATION_SERVICE_ERROR, (_, error) => // do something);
// Send FCM token to backend
ipcRenderer.on(TOKEN_UPDATED, (_, token) => // Send token);
// Display notification
ipcRenderer.on(ON_NOTIFICATION_RECEIVED, (_, notification) => // display notification);
// Start service
ipcRenderer.send(START_NOTIFICATION_SERVICE, senderId);

in the main process:

setupPushReceiver(mainWindow.webContents);

I received the following error when running the electron app, when it is setting up the push receiver :

PUSH_RECEIVER:::Error while starting the service TypeError: Object has been destroyed
at WebContents..send (electron/js2c/browser_init.js:173:2098)
at IpcMainImpl. (/Users/pianokai/Sites/restvo/front/electron/node_modules/electron-push-receiver/src/index.js:55:19)
(node:81584) UnhandledPromiseRejectionWarning: TypeError: Object has been destroyed
at WebContents.
.send (electron/js2c/browser_init.js:173:2098)
at IpcMainImpl. (/Users/pianokai/Sites/restvo/front/electron/node_modules/electron-push-receiver/src/index.js:59:19)

upon further investigation, it seems like it crashed in src/index.js line 52 - 55

      // Listen for GCM/FCM notifications
      await listen(Object.assign({}, credentials, { persistentIds }), onNotification(webContents));
      // Notify the renderer process that we are listening for notifications
      webContents.send(NOTIFICATION_SERVICE_STARTED, credentials.fcm.token);
@calvinckho
Copy link
Author

#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant