Blogs Engineering

Reconnecting Mercur's Algolia Sync to Inventory and Shipping Changes

Artículo en inglés. Five Algolia subscribers in Mercur listened for events nothing emitted. The merged fix adds a bridge that maps core change events onto them.

TypeScriptmercurjs/mercurMedusaAlgoliaevent-driven

Five subscribers that were wired up but never triggered, and the bridge that triggers them.

respuesta corta

Mercur's Algolia registry block listened for five "intermediate" events about inventory, stock locations, fulfillment sets, service zones and shipping options, but nothing in the codebase emitted them. After a product was first indexed, those changes never refreshed its Algolia record. The fix adds a subscriber that listens to the underlying module events and re-emits the matching intermediate events. It was merged as PR #1416 and closed issue #1244.

The problem

Mercur is an open-source multi-vendor marketplace platform built on Medusa. Issue #1244 laid out the regression in detail. Emitters added in an earlier PR "appear to have been lost when the monorepo was split into plugins/registry". The subscribers moved into the registry package; the emitters did not.

The fix

A new subscriber, algolia-intermediate-events-bridge.ts, maps module events to intermediate events:

const INTERMEDIATE_EVENT_BY_SOURCE: Record<string, IntermediateEvents> = {
  ...mapToIntermediateEvent(
    `${Modules.INVENTORY}.inventory-item`,
    IntermediateEvents.INVENTORY_ITEM_CHANGED
  ),
  ...mapToIntermediateEvent(
    `${Modules.STOCK_LOCATION}.stock-location`,
    IntermediateEvents.STOCK_LOCATION_CHANGED
  ),
  ...
}

Inventory-level events are resolved to their inventory item IDs before re-emitting. The new file is also registered in the block's registry manifests so it ships with the block.

By the numbers

  • Repository: mercurjs/mercur, 1,880 stars (Nov 3, 2026), TypeScript, MIT
  • Files changed: 4
  • Lines: +148 / -1
  • Commits: 3 (2 from the PR author, 1 maintainer merge of main)
  • Opened: Aug 21, 2026. Merged: Aug 31, 2026. Time to merge: 9 days, 21 hours
  • Review: merged by a maintainer after one review comment

How the review went

The maintainer spotted a gap within half an hour: "algolia/subscribers/algolia-intermediate-events-bridge.ts I dont see this new file in registry". The first commit had listed the file in the registry manifests without adding the source file itself. The follow-up commit added it, and the maintainer merged the PR. The original PR body also retained a tooling placeholder saying its structured explanation was incomplete; that text is not evidence of validation.

Preguntas frecuentes

Did the fix add tests?

No test file is included in the merged diff.

Where can I read more?

See the pull request and the original issue.

el objetivo

Refactors lose wiring. A bridge that restores it in one place, rather than re-adding emit calls in every route, keeps the event flow easy to see.

Ejecuta el ciclo

Convierte señales de producción en fixes revisados.

Empieza una prueba gratuita y descubre cómo Prilog conecta incidentes reales con pull requests a nivel de código.