Closed josepot closed 1 year ago
If the followSubscription gets invalidated before data retrieval, the response will be a JSON-RPC error.
The response is actually null
, not a JSON-RPC error. It's written in the spec.
There's also a note specifically for this:
Note: As explained in the documentation of chainHead_unstable_follow, the JSON-RPC server reserves the right to kill an existing subscription and unpin all its blocks at any moment in case it is overloaded or incapable of following the chain. If that happens, chainHead_unstable_header will return null.
If the followSubscription gets invalidated before data retrieval, the response will be a JSON-RPC error.
The response is actually
null
, not a JSON-RPC error. It's written in the spec.
Thanks for pointing that out! I actually missed that, my bad!
However, what about the other requests: chainHead_unstable_call
, chainHead_unstable_unpin
, chainHead_unstable_storage
, etc:
Will the server still dispatch a response, even after a stop event? will it be a JSON-RPC error? 🙏
However, what about the other requests: chainHead_unstable_call, chainHead_unstable_unpin, chainHead_unstable_storage, etc:
It's also written in the spec.
For call, body, storage:
If the followSubscription is invalid or stale, then "result": "limitReached" is returned (as explained above).
For unpin:
No error is generated if the followSubscription is invalid or stale. The call is simply ignored.
Thanks! Ok, now I get it. Sorry about that. So, basically, the only call that may not receive a response if "caught in the middle" is unpin
, which kinda makes sense.
So, it could happen that the client sends an unpin
request before the client has received the stop event, however the server was about to send it (or it had already sent it, but the client hadn't received it yet), in which case the server won't bother to respond back to the unpin
request... I mean, for the sake of consistency, I would much rather getting back a response with an error or something, but it's not a big deal, I guess. Thanks!
While working on the tests for the
@capi/substrate-client
, I encountered an ambiguity that requires clarity.Consider this scenario:
chainHead_unstable_header
.stop
event is triggered.This raises some questions:
Responsiveness: Will the server still dispatch a response to the
chainHead_unstable_header
request, even after astop
event?Response Type: If a response is sent, can we expect one of two outcomes?
followSubscription
was invalidated.followSubscription
gets invalidated before data retrieval, the response will be a JSON-RPC error.Generalization: Does this behavior also apply to operation requests like
chainHead_unstable_storage
et al?To sum up, I am operating under the assumption that a response will always be sent. For operation requests, any response type would result in the consumer receiving an
ErrorDisjoined
rejection. For non-operation requests likechainHead_unstable_header
, I plan to forward the response as it is.cc @tomaka