# no-async-endpoint-handlers

Rule `oxc/no-async-endpoint-handlers`. Disallows the use of `async` functions as Express endpoint handlers.

- Source: oxc
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 2.1M weekly downloads of presets that enable it
- Trend: +151.7% last quarter
- Rank: #1533 by reach, #37 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Oxlint | `oxc/no-async-endpoint-handlers` | no | no | plugin `oxc`, category suspicious | [docs](https://oxc.rs/docs/guide/usage/linter/rules/oxc/no-async-endpoint-handlers.html) |

## Code examples

### Incorrect: the rule reports this

```js
const app = express()
app.get('/', (req, res, next) => {
  new Promise((resolve, reject) => {
      return User.findById(req.params.id)
  })
    .then(user => res.json(user))
    .catch(next)
})
```

```js
const app = express()
app.get('/', async (req, res) => {
  // Server will crash if User.findById rejects
  const user = await User.findById(req.params.id)
  res.json(user)
})
```

```js
const app = express();
app.get('/', async (req, res) => {
  const user = await User.findById(req.params.id);
  res.json(user);
});

const router = express.Router();
router.use(async (req, res, next) => {
  const user = await User.findById(req.params.id);
  req.user = user;
  next();
});

const createUser = async (req, res) => {
  const user = await User.create(req.body);
  res.json(user);
}
app.post('/user', createUser);

// Async handlers that are imported will not be detected because each
// file is checked in isolation. This does not trigger the rule, but still
// violates it and _will_ result in server crashes.
const asyncHandler = require('./asyncHandler');
app.get('/async', asyncHandler);
```

### Correct: the rule accepts this

```js
const app = express();
// not async
app.use((req, res, next) => {
  req.receivedAt = Date.now();
})

app.get('/', (req, res, next) => {
  fs.readFile('/file-does-not-exist', (err, data) => {
    if (err) {
      next(err) // Pass errors to Express.
    } else {
      res.send(data)
    }
  })
})

const asyncHandler = async (req, res) => {
  const user = await User.findById(req.params.id);
  res.json(user);
}
app.get('/user', (req, res, next) => asyncHandler(req, res).catch(next))
```

Examples from the Oxlint documentation.

## Enable it

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "oxc/no-async-endpoint-handlers": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [oxc/no-accumulating-spread](https://lintradar.dev/rules/oxc/no-accumulating-spread.md): Prevents using object or array spreads on accumulators in `Array.prototype.reduce()` and in loops.
- [oxc/no-barrel-file](https://lintradar.dev/rules/oxc/no-barrel-file.md): Disallow the use of barrel files where the file contains `export *` statements, and the total number of modules exceeds a threshold.
- [oxc/misrefactored-assign-op](https://lintradar.dev/rules/oxc/misrefactored-assign-op.md): Https://rust-lang.github.io/rust-clippy/master/#/misrefactored_assign_op
- [oxc/no-const-enum](https://lintradar.dev/rules/oxc/no-const-enum.md): Disallow TypeScript `const enum`
- [oxc/approx-constant](https://lintradar.dev/rules/oxc/approx-constant.md): Disallows the use of approximate constants, instead preferring the use of the constants in the `Math` object.
- [oxc/no-this-in-exported-function](https://lintradar.dev/rules/oxc/no-this-in-exported-function.md): Disallows the use of `this` in exported functions.

---

Web page: https://lintradar.dev/rules/oxc/no-async-endpoint-handlers. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
