Skip to content

Commit

Permalink
Fix indexation component
Browse files Browse the repository at this point in the history
* an error would result in an infinite loop: add url = false
* an error would not result in the error being displayed: add wait for next cycle
* the above fixes the indexation tests
  • Loading branch information
igorschoester committed Apr 27, 2024
1 parent 6366a02 commit c5320d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/js/src/components/Indexation.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ class Indexation extends Component {
firstTime: false,
} );
} );

url = false;
}
}
}
Expand All @@ -168,6 +170,10 @@ class Indexation extends Component {
for ( const endpoint of Object.keys( this.settings.restApi.indexing_endpoints ) ) {
await this.doIndexing( endpoint );
}

// Wait until the next cycle, to make sure the state is updated before checking it.
await new Promise( resolve => setTimeout( resolve, 0 ) );

/*
* Set the indexing process as completed only when there is no error
* and the user has not stopped the process manually.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class Indexation extends Component {
firstTime: false,
} );
} );

url = false;
}
}
}
Expand All @@ -171,6 +173,10 @@ class Indexation extends Component {
for ( const endpoint of Object.keys( this.settings.restApi.indexing_endpoints ) ) {
await this.doIndexing( endpoint );
}

// Wait until the next cycle, to make sure the state is updated before checking it.
await new Promise( resolve => setTimeout( resolve, 0 ) );

/*
* Set the indexing process as completed only when there is no error
* and the user has not stopped the process manually.
Expand Down

0 comments on commit c5320d8

Please sign in to comment.