-
Notifications
You must be signed in to change notification settings - Fork 420
Description
Is your feature request related to a problem?
PersistedQueryNotFound errors show up occasionally when running the miner. I believe there are 2 causes:
- The Twitch server handling the miner's GQL requests is new (perhaps from a scale up/restart/update) and has yet to receive any requests for the attempted operation from a genuine Twitch client.
- The operation definition has changed and so the server no longer recognises the hash the miner is using.
The apollo persisted query docs define 2 types of persisted queries: regular and automatic (APQs). I believe Twitch is using the automatic variant as they don't seem to have a client operation manifest file (I might have just missed it though).
Proposed solution
It may be possible to automatically handle some PersistedQueryNotFound errors, specifically errors causes by the first case outlined above. I propose we could automatically handle errors where the definition hasn't changed (and so the hash also hasn't changed) by implementing the spec for APQs which involves building the query we want to make manually and sending the hash along with it. We should also try and find example of the official Web Client doing this to capture all the expected request headers.
To people who are familiar with any of this, does this seem like a reasonable approach?
Alternatives you've considered
We could easily leave the miner as is, the current solution works. The main disadvantage of how we currently handle it is that we occasionally run into situations where PersistedQueryNotFound errors happen and people think it's a problem with the miner when it's something that will resolve itself within a few minutes.
The main disadvantage with the proposed solution is that it adds complexity and solves a problem that generally gets resolved within a few minutes.
Additional context
We should only do this by reusing the old hash as if the operation/hash has changed then the operation may not align with our current usage. In this case, the miner would have to be updated with the new hash (potentially more if the operation is no longer supported or it's meaning has changed) as is currently the case. I say this as it is technically possible to extract the expected hash for a query from the Twitch Web Client source code, by searching for the OperationDefinition for a given operation and hashing the query generated. In fact, this may be necessary in order to check if the hash has changed.