elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.23k stars 198 forks source link

`afterHandle` executes even after validation fails #602

Closed touhidurrr closed 3 months ago

touhidurrr commented 3 months ago

What version of Elysia.JS is running?

1.0.13

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

Make some path with afterHandle, add some validation, intentionally do something that would fail the validation. Maybe something like:

import { Elysia, t } from 'elysia';

new Elysia()
  .get('/test/:num', ({ params: { num } }) => num, {
    params: t.Object({ num: t.Numeric() }),
    afterHandle: ({ request: { method, url } }) =>
      console.log(`afterHandle on ${method} ${url}`),
  })
  .listen(3000);

What is the expected behavior?

If validation fails, afterHandle is ignored.

What do you see instead?

If validation fails, afterHandle is executed.

Additional information

No response

touhidurrr commented 3 months ago

Closing because I cannot reproduce my own issue. Sigh.