-
Notifications
You must be signed in to change notification settings - Fork 49
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 session stores don't work with newer versions of nodejs #254
Comments
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests. |
We are facing the same problem. It is hard to narrow down, but imho a critical bug. |
Looking through the code, I don't think any methods of
It is also hard for us to pin point the cause if no reproducible code is provided. |
I'm having a similar issue, although my Node.js version is
I'm trying to use a session store made for the Prisma ORM. In this error I'm using the I also tried writing my own session store which doesn't have async functions and it works, but I seemingly randomly get this in my logs which is very annoying:
I have no idea what I'm supposed to do here as the error comes from inside Fastify and @fastify/session. I have no way to affect anything in the session logic beyond the store interface and nothing I've tried seems to make these issues go away. Fastify version is 4.16.0, @fastify/session is 10.9.0. |
Still seem to be getting this as well with error handling included (I posted the original issue). I will try to look into this. |
I made a repo to replicate this issue and played around a bit with different configurations. This led me to find the fix (in my application code, not fastify-session) which is to ALWAYS RETURN For those of you getting this issue intermittently, go through all your async handlers and ensure that you have something to the effect of
|
Prerequisites
Fastify version
4.27.0
Plugin version
10.8.0
Node.js version
20.x
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
docker
Description
This was reported in #252 but the issue was closed due to a particular implementation flaw by the poster. However the problem seems more widespread than just his issue with handling errors.
Asynchronous methods on the session store (which is required by almost any production session store to persist in a database) cause an error with node versions starting at node 20. Works fine with node 19.
As a minimum repoducible example, I've narrowed it down to adding a simple setTimeout in the default in-memory store causes the bug to occur.
When using this store in a fastify app such as (simplified)
It throws this error and exits the process
This is on
Node.js v20.13.1
but it affects any version of node since 20.x. Previously known working version was node 19.Link to code that reproduces the bug
No response
Expected Behavior
I expect it to work on node 20 the same way it did on node 19 or prior.
Any sensible session store requires some asynchronous operation to set and get, so if my diagnosis is correct, this is a major issue.
The text was updated successfully, but these errors were encountered: