Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When aot is false, error responses return a 500 #974

Open
jasperdunn opened this issue Dec 24, 2024 · 1 comment · May be fixed by #976
Open

When aot is false, error responses return a 500 #974

jasperdunn opened this issue Dec 24, 2024 · 1 comment · May be fixed by #976
Labels
bug Something isn't working

Comments

@jasperdunn
Copy link

What version of Elysia is running?

1.2.4

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

When aot is false, error responses don't work.

new Elysia({ aot: false })
 .get('/', ({ error }) => {
    return error(400);
  })

What is the expected behavior?

400 status code

What do you see instead?

500 status code with message: error4 is not a function

Additional information

No response

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

Yes

@jasperdunn jasperdunn added the bug Something isn't working label Dec 24, 2024
@jasperdunn jasperdunn changed the title error4 is not a function When aot is false, error responses return a 500 with the message - error4 is not a function Dec 24, 2024
@jasperdunn jasperdunn changed the title When aot is false, error responses return a 500 with the message - error4 is not a function When aot is false, error responses return a 500 Dec 24, 2024
@bogeychan bogeychan linked a pull request Dec 25, 2024 that will close this issue
@shiny
Copy link

shiny commented Feb 5, 2025

I’m having the same issue as well, elysiajs version 1.2.12
I am also looking for an alternative way to write this as a temporary solution, which is why I used the following approach:

direct import error from elysia

import { Elysia, error } from 'elysia'
new Elysia({
    aot: true
})
.derive(() => {
    return error(401)
})
.get('/', 'ok')
.listen(3000)
// http://127.0.0.1:3000 shows `Unauthorized`

Unfortunately, this alternative solution is still affected by the AOT flag. When AOT is set to false, the error returned in derive will be ignored. This is weird and counterintuitive.

import { Elysia, error } from 'elysia'
new Elysia({
    aot: false
})
.derive(() => {
    return error(401)
})
.get('/', 'ok')
.listen(3000)
// http://127.0.0.1:3000 shows `ok`

but I have to turn aot off for the reason #943 😮‍💨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants