holochain / holochain-client-js

A JavaScript client for the Holochain Conductor API
Other
258 stars 16 forks source link

Response tags not checked #234

Open ThetaSinner opened 6 months ago

ThetaSinner commented 6 months ago

Through my exploration (read incompetence :)) I found that it's possible to get bad responses from Holochain that aren't caught by the client.

See what happened on https://github.com/holochain/hc-spin/issues/3#issuecomment-1970088485. Basically, calling Holochain 0.3 with a 0.2 client, which we know won't work but I'd have expected an error from the client.

I see that strings like 'clone_cell_created' aren't found in this project which is as deep as I've gone, but I believe that means the client isn't checking that Holochain responds to create_clone_cell with a message tagged with clone_cell_created. That means that deserialisation errors are passed back to the caller.

I think the Rust client will catch this because it deserializes to strict types. My question is whether the JS client should catch this? I'm thinking it should go ahead and throw an error with the contents of the response if it doesn't match. I'll post this in the API guild tomorrow because I think this behaviour should probably be something we decide on for clients in general.

ThetaSinner commented 6 months ago

Ping @jost-s

jost-s commented 6 months ago

Yes, I agree to include this in the client. I've been wanting to refactor the websocket implementation and typings and make it easier to read with less nested functions. This could be part of it.