CardanoSolutions / ogmios

❇️ A WebSocket JSON/RPC bridge for Cardano
https://ogmios.dev
Mozilla Public License 2.0
304 stars 90 forks source link

clients/TypeScript: Remove or document invalid use of `InteractionContext` with standalone queries #40

Closed rhyslbw closed 3 years ago

rhyslbw commented 3 years ago

Describe your idea, in simple words.

https://github.com/KtorZ/cardano-ogmios/pull/37#discussion_r627042048

Why is it a good idea?

https://github.com/KtorZ/cardano-ogmios/pull/37#discussion_r626759455

Are you willing to work on it yourself?

Yes

rhyslbw commented 3 years ago

UnknownResultError is actually just a guard against response.result not equalling RollBackward or RollForward if response.methodname === 'RequestNext'. https://github.com/KtorZ/cardano-ogmios/blob/990ffa69f006f3ab82ebfe84997f4a8541697cbc/clients/TypeScript/packages/client/src/ChainSync/ChainSyncClient.ts#L44-L60

The standalone queries handlers use a request identifier: https://github.com/KtorZ/cardano-ogmios/blob/990ffa69f006f3ab82ebfe84997f4a8541697cbc/clients/TypeScript/packages/client/src/StateQuery/queries/ledgerTip.ts#L19

... however since the listener is registered with once, there still is a scenario where the handler could be torn down prior to receiving the query result. I'll see if there's another way to manage the listener tear down @KtorZ

https://github.com/KtorZ/cardano-ogmios/blob/990ffa69f006f3ab82ebfe84997f4a8541697cbc/clients/TypeScript/packages/client/src/StateQuery/queries/ledgerTip.ts#L17