Back to Medusa

{metadata.title}

www/apps/resources/app/lint/rules/scheduled-job-default-export-async/page.mdx

2.17.01.1 KB
Original Source

export const metadata = { title: scheduled-job-default-export-async - ESLint plugin rules, }

{metadata.title}

This rule requires the default-exported scheduled job function to be async.

Severity

error. This rule is enabled in the recommended preset.

What it Targets

This rule targets files in your project's src/jobs directory. It reports a default-exported scheduled job that isn't an async function.

The following code is reported by the rule:

ts
export default function syncProducts() {}

Instead, make the job function async:

ts
export default async function syncProducts() {}

Why it's Important

Scheduled jobs receive the Medusa container and are always awaited by Medusa. Making the job async ensures Medusa can wait for its work to finish before continuing.

Learn more in the Scheduled Jobs documentation.

Fixable

This rule is auto-fixable. Run the linter with the --fix option to apply the fix automatically.