You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Elysia}from"elysia";importassertfrom"node:assert";consthostname="127.0.0.1";constport=8089;constapp=newElysia();// using this request:// http://localhost:8089/foo/bar?foo=bar&bar=bazapp.get("/foo/bar",async(ctx)=>{console.log(ctx.query);// request with just the console.log above (commenting out the console.logs below)/*Listening on 127.0.0.1:8089{ query: undefined,}*/// when you add the following three console.log s:// console.log(JSON.stringify(ctx.query));// console.log(ctx.query.foo);// console.log(ctx.query.bar);/*Listening on 127.0.0.1:8089{ query: undefined, "query)": undefined, foo: "bar", bar: "baz",}{"foo":"bar","bar":"baz"}barbaz*/});app.listen({
hostname,
port,});assert.ok(app.server);console.log(`Listening on ${app.server.hostname}:${app.server.port}`);
What is the expected behavior?
For ctx.query to actually be a correct object containing all of the query parameters in the request.
What do you see instead?
See repro comments.
Additional information
Taking a glance at the codebase, it appears to be because elysia tries to be "smart" with figuring out what the route handler wants to access, and codegens around it. Why? Why is this a thing??? I understand that it may be for "performance reasons" but in place of it you open up a GIGANTIC can of worms causing issues such as above because people can't expect their code to work as it normally does within normal javascript execution. I am very much okay taking a perf hit if it means that the library I use doesn't try to be fancy with metaprogramming like this, potentially exposing my code to critical error paths.
The text was updated successfully, but these errors were encountered:
Thanks, I wasn't aware of that option. It's still a pretty nasty surprise learning that this was a thing Elysia did, especially given how this appears to not be the only bug relating to it. I would feel a lot more confident in Elysia if it had it disabled by default, instead letting the user opt into it in the docs, after warning about its potential volatility.
What version of Elysia.JS is running?
elysia@1.0.15, bun 1.1.7
What platform is your computer?
Linux 6.4.9-arch1-1 x86_64 unknown
What steps can reproduce the bug?
What is the expected behavior?
For ctx.query to actually be a correct object containing all of the query parameters in the request.
What do you see instead?
See repro comments.
Additional information
Taking a glance at the codebase, it appears to be because elysia tries to be "smart" with figuring out what the route handler wants to access, and codegens around it. Why? Why is this a thing??? I understand that it may be for "performance reasons" but in place of it you open up a GIGANTIC can of worms causing issues such as above because people can't expect their code to work as it normally does within normal javascript execution. I am very much okay taking a perf hit if it means that the library I use doesn't try to be fancy with metaprogramming like this, potentially exposing my code to critical error paths.
The text was updated successfully, but these errors were encountered: