Skip to content

Commit

Permalink
feat(pouch-link): Allow to ignore warmup
Browse files Browse the repository at this point in the history
With previous changes, we now expect the CozyPouchLink to be the last
link of the chain, so forwarding the query would result to an exception
thrown

This mean we cannot forward the query when warmup queries are not
finished yet

So we want to allow CozyPouchLink to ignore the verification step and
process the query independently of the warmup queries status

To allow this we introduce the `ignoreWarmup` parameter. When set to
`true` the CozyPouchLink will process the query even if warmup is not
finished yet
  • Loading branch information
Ldoppea committed Aug 13, 2024
1 parent e730c22 commit bb43ae9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/cozy-pouch-link/src/CozyPouchLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PouchLink extends CozyLink {
constructor(opts) {
const options = defaults({}, opts, DEFAULT_OPTIONS)
super(options)
const { doctypes, doctypesReplicationOptions } = options
const { doctypes, doctypesReplicationOptions, ignoreWarmup } = options
this.options = options
if (!doctypes) {
throw new Error(
Expand All @@ -96,6 +96,7 @@ class PouchLink extends CozyLink {
this.storage = new PouchLocalStorage(
options.platform?.storage || platformWeb.storage
)
this.ignoreWarmup = ignoreWarmup

/** @type {Record<string, ReplicationStatus>} - Stores replication states per doctype */
this.replicationStatus = this.replicationStatus || {}
Expand Down Expand Up @@ -361,7 +362,7 @@ class PouchLink extends CozyLink {
return forward(operation)
}

if (await this.needsToWaitWarmup(doctype)) {
if (!this.ignoreWarmup && (await this.needsToWaitWarmup(doctype))) {
if (process.env.NODE_ENV !== 'production') {
logger.info(
`Tried to access local ${doctype} but not warmuped yet. Forwarding the operation to next link`
Expand Down

0 comments on commit bb43ae9

Please sign in to comment.