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
Async Derive leaks request context to other requests if aot:true
#466
Comments
worth noting this also extends to request validation, etc. It seems the context of the new request just entirely replaces the context of the old request. |
Fixed on #465, waiting for merge. |
When using derive |
I originally ran into this when it was an async function that returned a |
Circling back to this, the issue I ran into is present on 1.0.0-beta.2 I don't think it's fixed on #465 |
do you have a repro for this? the reproduction above works fine in 1.0.0-beta.2 |
I currently do not have a sharable reproduction, but I have definitely tracked down the issue. So the built version of Elysia 1.0.0-beta.2 has a file derive<const Derivative extends Record<string, unknown>>(transform: (context: Prettify<Context<Metadata['schema'], Singleton>>) => MaybePromise<Derivative> extends {
store: any;
} ? never : Derivative): Elysia<BasePath, Scoped, {
decorator: Singleton['decorator'];
store: Singleton['store'];
derive: Prettify<Singleton['derive'] & Awaited<Derivative>>;
resolve: Singleton['resolve'];
}, Definitions, Metadata>; It's being set here Lines 4497 to 4519 in ff5d5ac
and I've determined that my error is coming from the ternary in the callback's return type for Note that the I made a PR to fix the issue #484 which gets rid of the ternary, I'm not really sure what it's purpose was to begin with but I could be missing something since I'm not as familiar with the codebase as @SaltyAom or other contributors. |
I've updated my PR. #488 |
Merged #488. If resolved, please leave the issue opened until release on next stable release. |
Should be fixed in 1.0.0 Feels free to reopen if issue still persists. |
What version of Elysia.JS is running?
0.8.16
What platform is your computer?
Microsoft Windows NT 10.0.22621.0 x64
What steps can reproduce the bug?
have an async derive hook in an elysia instance with
aot: false
;What is the expected behavior?
async derive in aot:false environment should not leak contexts between requests
What do you see instead?
context from newer requests leaks into the handlers of old requests
Additional information
reproduction code:
the above code, when run, logs
http://localhost:1025/bad
, expected behavior is to loghttp://localhost:1025/test
;The text was updated successfully, but these errors were encountered: