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

Redis ClientClosedError after cookie is set #48

Closed
Alphacode18 opened this issue Dec 25, 2021 · 4 comments
Closed

Redis ClientClosedError after cookie is set #48

Alphacode18 opened this issue Dec 25, 2021 · 4 comments

Comments

@Alphacode18
Copy link

Alphacode18 commented Dec 25, 2021

I am currently implementing sessions with Redis. I have followed along and have spent sometime debugging on my own, but I can't seem to solve this error.

I am able to send a request, a cookie is set but the server promptly crashes after that with this promise rejection. Any ideas as to what may be going wrong?

Repository: https:/Alphacode18/Lireddit

[discovery] ORM entity discovery started, using ReflectMetadataProvider
[discovery] - processing entity Post
[discovery] - processing entity User
[discovery] - entity discovery finished, found 2 entities, took 23 ms
[info] MikroORM successfully connected to database lireddit on postgresql://[email protected]:5432
[query] select table_name, nullif(table_schema, 'public') as schema_name from information_schema.tables where table_schema not like 'pg_%' and table_schema != 'information_schema' and table_name != 'geometry_columns' and table_name != 'spatial_ref_sys' and table_type != 'VIEW' order by table_name [took 19 ms]
[query] begin
[query] select * from "mikro_orm_migrations" order by "id" asc [took 26 ms]
[query] commit
The server is listening at port 4000
[query] begin
[query] insert into "user" ("created_at", "password", "updated_at", "username") values ('2021-12-25T04:59:34.507Z', '$argon2i$v=19$m=4096,t=3,p=1$ViITDRSY8RBzNYEcZMMZ8A$ZrXebolYIvlbyDx3WFzop/xwPDll4dx/ASz4oKnCL88', '2021-12-25T04:59:34.507Z', 'sham') returning "id" [took 30 ms]
[query] commit
/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/@node-redis/client/dist/lib/client/index.js:393
        return Promise.reject(new errors_1.ClientClosedError());
                              ^
ClientClosedError: The client is closed
    at Commander._RedisClient_sendCommand (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/@node-redis/client/dist/lib/client/index.js:393:31)
    at Commander.commandsExecutor (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/@node-redis/client/dist/lib/client/index.js:160:154)
    at Commander.BaseClass.<computed> [as set] (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/@node-redis/client/dist/lib/commander.js:8:29)
    at RedisStore.set (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/connect-redis/lib/connect-redis.js:65:21)
    at Session.save (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/express-session/session/session.js:72:25)
    at Session.save (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/express-session/index.js:406:15)
    at ServerResponse.end (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/express-session/index.js:335:21)
    at ServerResponse.send (/Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/express/lib/response.js:221:10)
    at /Volumes/G-DRIVE mobile SSD R-Series/Development/lireddit/node_modules/apollo-server-express/dist/ApolloServer.js:89:25
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
[nodemon] app crashed - waiting for file changes before starting...
@han109k
Copy link

han109k commented Jan 4, 2022

I happen to have this same error and wondering if you solved this or not?

@Alphacode18
Copy link
Author

Alphacode18 commented Jan 4, 2022

@han109k No, I'm still waiting on a reply! Though I'm thinking of using the ioredis package to see if it makes a difference.

@benawad is busy with Voidpet it seems 😅

@han109k
Copy link

han109k commented Jan 4, 2022

I think I got solved the problem for now at least. You just need to change the redis configuration part:

import { createClient } from 'redis';
const redisClient = createClient({ legacyMode: true });
await redisClient.connect();

connect-redis's new version causes an issue I guess

@Alphacode18
Copy link
Author

@han109k Yes, this fixes it! Agreed, connect-redis' version difference seems to be the issue. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants