iron-fish / node-app

Electron-based Node App
https://ironfish.network/use/node-app
17 stars 8 forks source link

Wrap IPC response data in object #393

Closed dguenther closed 1 year ago

dguenther commented 1 year ago

If an error is thrown as a result of executing a handler on the main process, a response is returned across the IPC bridge with an object containing { error: true }. Then on the renderer side, in the invoke util, the function watches for truthy values of error, and if it sees one, it throws the response.

However, in the snapshot manager, we return objects that include an error field, which ends up getting thrown by the invoke util. This is probably not intended behavior -- I'd lean toward establishing a pattern where unrecoverable or unintended errors are thrown, and recoverable errors are returned on the response body.

To avoid this, I wrapped successful responses in { error: false, data: object } and returned the response body on the data field instead.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
wallet-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 15, 2023 9:26pm