medusajs/medusa

[Bug]: Workflows are not being picked up by worker if the file is named index.[js,ts]

Chiusa

#15.442 aperta il 20 mag 2026

 (2 commenti) (0 reazioni) (0 assegnatari)TypeScript (2090 fork)batch import
good first issuetype: bugversion: 2.0

Metriche repository

Star
 (22.539 stelle)
Metriche merge PR
 (Merge medio 10g 22h) (185 PR mergiate in 30 g)

Descrizione

Package.json file

N/A

Node.js version

v22.0.0

Database and its version

16.2

Operating system name and version

N/A

Browser name

No response

What happended?

When the workflow loader runs, it excludes index.[js,ts] files since they are usually used for barrel exports (but not always), as seen here. If the index file exports an actual workflow, it will not work due to this filtering

Why would this typically work with a WORKER_MODE=server/shared? Typically workflows are called from HTTP routes - when the HTTP routes are loaded the workflows will get registered implicitly as well. However, a WORKER_MODE=worker instance never loads the HTTP routes, and therefore never loads the workflow.

Expected behavior

All workflows are loaded, regardless of the file name

Actual behavior

Workflows in index.ts file are not loaded

Link to reproduction repo

N/A

Guida contributor