Does not work `@electron/remote` in the plugin

Bug report

I am in the process of fixing require('electron').remote from the latest version of Inkdrop as it no longer works.

require('electron').remote is no longer available for plugins. Use require('@electron/remote') instead.

Related issue:

I am working on replacing @electron/remote in this branch, but when I switch notes several times, I get the following error and the app crashes.
Do you know what causes this?

Error: Cannot get property '_id' on missing remote object 591
    at throwRPCError (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/@electron/remote/dist/src/main/server.js:196:19)
    at /Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/@electron/remote/dist/src/main/server.js:483:13
    at IpcMainImpl.<anonymous> (/Applications/Inkdrop.app/Contents/Resources/app.asar/node_modules/@electron/remote/dist/src/main/server.js:322:27)
    at IpcMainImpl.emit (node:events:394:28)
    at IpcMainImpl.emit (node:domain:475:12)
    at Object.<anonymous> (node:electron/js2c/browser_init:161:10774)
    at Object.emit (node:events:394:28)
    at Object.emit (node:domain:475:12)

Environment

  • Platform: macOS
  • Platform version: Monterey
  • App Version:5.5.0

How to reproduce

  1. git clone git@github.com:seachicken/inkdrop-pomodoro-edit.git -b issue7-wip
  2. cd inkdrop-pomodoro-edit
  3. ipm link --dev
  4. Switch the note about 5 times
  5. An error occurs

Hi Seito-san,

Thanks for the report. That’s weird. I’ll look into it!

Oh, it looks like you’ve added @electron/remote as a dependency to your plugin. It’s unnecessary because Inkdrop provides it out of the box. Can you try removing it?

1 Like

Wow! Thank you Takuya.
I removed the dependencies and it worked.

1 Like

Nice!