graphql - await initial replication resolves on failed replication #2745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains:
Describe the problem you have without this PR
I experienced that
awaitInitialReplication()
of the graphql replicator plugin resolves even if the replication never succeeds (see attached issue). Is this the expected behavior?Path of issue
syncGraphQL()
executesreplication.run()
(see code) without param and thus the defaultretryOnFail = true
is used. If this first pull cycle failsrun()
is executed with the default param again (code). Works as expected.The problem is that
syncGraphQL
executesrun(false)
on every following pull sync cycle everyliveInterval
ms (code). Ifrun(false)
is executed and failsthis._run(retryOnFail=false)
returns false, the following if check resolves andinitialReplicationComplete
emits true:(code)
Fix
Simply adding
retryOnFail
to the if statement fixes the issue. Thus, only the initial replication cycle and every retry execution of run() are able to emittrue
tothis.subjects.initialReplicationComplete
.Discuss
The current behavior of
awaitInitialReplication()
is that it neither resolves nor rejects if the replication stays erroneous. I'm thinking about if it would be useful to reject the promise and cancel the whole replication after an specific timeout that can be set by the user because this timeout hardly depends on the amount of data pulled initially. Could be implemented withPromise.race()
and an timeout Promise in theawaitInitialReplication()
method. Looking forward to discus 👍Todos