Chore(index): Sync logs management (#11522)

**What**
- Add index engine sync log information
- Ad `setTimeout(0)` to give breath to the event loop and ensuring not blocking the event loop and allow for other tasks queue execution to happen while syncing

here is an example:
**LOG_LEVEL=info**

![Screenshot 2025-02-19 at 10 09 25](https://github.com/user-attachments/assets/fc74dc32-1bc1-4123-9de3-f37817b7e783)

**LOG_LEVEL=debug**

![Screenshot 2025-02-19 at 10 10 35](https://github.com/user-attachments/assets/222a1ce1-9267-4cb0-9518-dc4c7aa2b6f4)
This commit is contained in:
Adrien de Peretti
2025-02-19 11:54:38 +00:00
committed by GitHub
parent 647077057c
commit 77f37c5f97
6 changed files with 57 additions and 9 deletions
@@ -31,6 +31,7 @@ Object.keys(config.modules).forEach((key) => {
config.modules[Modules.INDEX] = {
resolve: "@medusajs/index",
dependencies: [
ContainerRegistrationKeys.LOGGER,
Modules.EVENT_BUS,
Modules.LOCKING,
ContainerRegistrationKeys.REMOTE_QUERY,
@@ -133,7 +133,7 @@ describe("IndexModuleService syncIndexConfig", function () {
afterEach(afterEach_)
it.only("should full sync all entities when the config has changed", async () => {
it("should full sync all entities when the config has changed", async () => {
await setTimeout(1000)
const currentMetadata = await indexMetadataService.list()
@@ -191,6 +191,7 @@ describe("IndexModuleService syncIndexConfig", function () {
;(index as any).buildSchemaObjectRepresentation_()
let configurationChecker = new Configuration({
logger,
schemaObjectRepresentation: (index as any).schemaObjectRepresentation_,
indexMetadataService,
indexSyncService,
@@ -277,6 +278,7 @@ describe("IndexModuleService syncIndexConfig", function () {
)
configurationChecker = new Configuration({
logger,
schemaObjectRepresentation: (index as any).schemaObjectRepresentation_,
indexMetadataService,
indexSyncService,