medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.45k stars 2.4k forks source link

Meilisearch not recognised as search plugin because of dependencies #5546

Open ebdrup opened 10 months ago

ebdrup commented 10 months ago

Bug report

Describe the bug

Following the guide on how to install the meilisearch plugin, it was not indexing documents.

System information

Medusa version (including plugins): 6.1.3,

medusa-plugin-meilisearch": "2.0.10"

Node.js version: 2.8.0 Database: Postgresql Operating system: OSX Browser (if relevant):

Steps to reproduce the behavior

Follow the guide on how to install the meilisearch plugin, when you get to looking up the indexed documents in meilisearch, there will be no products in meilisearch. Also adding a product does not appear in meilisearch, even though the eventbus is installed correctly.

Expected behavior

Products indexed in meilisearch

Additional context

I debugged the problem myself:

meduas-plugin-meilisearch had @medusa/types in it's node_modules, so when checking the type of the search service it was categorising it as a generic plugin instead of a search plugin, because the instance of in ìsSearchService` check was checking a different type from the local @medusa/types Adding @medusa/types to the main package.json didn't work, but after i removed node_modules, and yarn.lock and did a clean yarn, it started working, because now meduas-plugin-meilisearch was using the same @medusa/types as the rest of the code.

To prevent this from happening in the future, I've added an override in my package.json

"overrides": {
    "medusa-plugin-meilisearch": {
      "@medusajs/types": "$@medusajs/types"
    }
  }

Potentially adding overrides in package.json for all medusa plugins that are using @medusajs/types might be a good idea, I guess.

pepijn-vanvlaanderen commented 8 months ago

Not sure if the plugin has been updated in the meantime. But currently the fix is to override the @medusajs/utils which is older for the meilisearch plugin.

@olivermrbl could some sort of protocol to check core plugin depencies to prevent these issues?

olivermrbl commented 8 months ago

Yes, I've been meaning to research a better approach for dependency management across packages, but haven't had the time yet.

There's no straightforward solution, and we are not the only ones to be struggling with it.

We are actively working on resolving some of the issues specific to plugins by removing checks like the instance of, which will fail when there's a dependency mismatch. See https://github.com/medusajs/medusa/pull/5869 for details about this.

Will get back when I have more to share.