AI-coding hygiene

no-floating-promise-handler

Require try/catch (or an async wrapper) on async Express/Fastify route handlers.

In Express 4 a rejected promise from a handler hangs the request forever; in some Express 5 setups it crashes the process. AI-generated route handlers ship this shape constantly. The rule accepts try/catch at the top level, a returned `.catch(next)`, or wrapping the handler in `asyncHandler` / `catchAsync` / `wrap` / `tryCatch`.

Behavior

  • Fixable: No.
  • Suggestions: No.

Examples

Bad:

app.get('/x', async (req, res) => { const u = await load(); res.json(u); });

Good:

app.get('/x', asyncHandler(async (req, res) => { const u = await load(); res.json(u); }));

Related rules

Use it

Enable no-floating-promise-handler in your eslint.config.js:

import deslint from '@deslint/eslint-plugin';

export default [
  {
    plugins: { deslint },
    rules: {
      'deslint/no-floating-promise-handler': 'error',
    },
  },
];

Found a false positive? Report it on GitHub →

Back to all rules