1 ---
2 sidebar_label: "subscriber-default-export-must-be-async"
3 ---
4
5 export const metadata = {
6 title: `subscriber-default-export-must-be-async - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires the default-exported subscriber handler function to be async.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets files in your project's `src/subscribers` directory. It reports a default-exported subscriber handler that isn't an async function.
20
21 The following code is reported by the rule:
22
23 ```ts title="src/subscribers/order-placed.ts"
24 export default function orderPlacedHandler() {}
25 ```
26
27 Instead, make the handler async:
28
29 ```ts title="src/subscribers/order-placed.ts"
30 export default async function orderPlacedHandler() {}
31 ```
32
33 ## Why it's Important
34
35 Subscribers receive an event and are always awaited by Medusa. Making the handler async ensures Medusa can wait for its work to finish before continuing.
36
37 Learn more in the [Subscribers documentation](!docs!/learn/fundamentals/events-and-subscribers).
38
39 ## Fixable
40
41 This rule is auto-fixable. Run the linter with the `--fix` option to apply the fix automatically.