electron中的IPC通信报错
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一下
各位大神有什么好的建议,能节省一点性能吗
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看下这里有没有帮助: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...