Skip to content

[Bug] Incorrect hook trigger order. #1826

@ListenV

Description

@ListenV

What version of Elysia is running?

1.4.28

What platform is your computer?

Linux 6.19.8-1.0.2.sr20260302-default x86_64 x86_64

What environment are you using

bun 1.3.11

Are you using dynamic mode?

No

What steps can reproduce the bug?

import { Elysia } from 'elysia'

const app = new Elysia()
  .get('/a', () => {
    console.log('A')
    return 'A'
  })
  .onBeforeHandle(()=> {
    console.log('1')
  })
  .get('/b', () => {
    console.log('B')
    return 'B'
  })
  .onBeforeHandle(()=> {
    console.log('2')
  })
  .get('/c', () => {
    console.log('C')
    return 'C'
  })
  .listen(4000)

What is the expected behavior?

Request /a, the console actually prints:

A

The result is correct!


Request /b, the console actually prints

1
2
B

The result is incorrect!

The correct result should be

1
B

Request /c, the console actually prints

1
2
C

The result is correct!

What do you see instead?

No response

Additional information

No response

Have you try removing the node_modules and bun.lockb and try again yet?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions