electron 中用IPC通信
如果传递的对象有方法就会报错
Uncaught (in promise) Error: An object could not be cloned.
at EventEmitter.i.invoke (electron/js2c/renderer_init.js:71)
at VueComponent.ipcTest (webpack-internal:///./src/renderer/mixins/index.js:8)
electron的IPC使用结构化克隆算法,可以理解没办法传function,但是尼玛为什么非要报错呢
他不能像序列化一样,直接忽略掉吗?
就很烦!我还得自己先json.stringify一下
各位大神有什么好的建议,能节省一点性能吗
看下这里有没有帮助:https://github.com/electron/e...
For anyone googling this error, this can also happen if a formerly synchronous function is suddenly made asynchronous, without the corresponding
await
in the caller. If the result was then sent via IPC, the serializer may not be able to handle this.This isn't a problem with Electron and the IPC, it's effectively the missing
await
before the IPC.(这不是Electron和IPC的问题,这是缺少await
的问题)I ran into this with the undocumented breaking changes made in
electron-settings
in its 4.0 major update (e.g.get
andset
are now async). I suspect the IPC is having trouble serializing a promise...