Code Monkey home page Code Monkey logo

Comments (12)

hvqzao avatar hvqzao commented on August 23, 2024 1

Hi @jackey8616 thank you for the support!
Well, the strange thing is that the issue got resolved by itself after some time (24h-48h) after applyling changes from 7.0.0 release notes to all my repositories that were using connect-redis. It could be that it was some caching issue. I don't know. What's important - right now it works 👍

from connect-redis.

wavded avatar wavded commented on August 23, 2024

The issue here is your are passing the session object into connect-redis. That is no longer required and will cause this error. See the migration notes for more details:

https://github.com/tj/connect-redis/releases/tag/v7.0.0

from connect-redis.

hvqzao avatar hvqzao commented on August 23, 2024

No, I'm not passing session object to connect-redis, this line is commented out:

  // const RedisStore = ConnectRedis(Session)

The problem is located here:

    store: RedisStore({
      client: redis
    })

I'm sorry but release notes do not mention this issue. How can I address that?
Could you point out an example Typescript code which works with ioredis or share an update to the repo I've mentioned earlier?

from connect-redis.

wavded avatar wavded commented on August 23, 2024

Ahh sorry, I must have looked at the wrong commit. The issue you have with the above code is you are not initializing the constructor with new. Should be new RedisStore({

from connect-redis.

hvqzao avatar hvqzao commented on August 23, 2024

Yes, that is also why I've commented out with new RedisStore({ as it caused different error.
RedisStore is defined as alias to a function:

(alias) function RedisStore(options: (options?: session.SessionOptions) => express.RequestHandler): s.RedisStore
(alias) namespace RedisStore
import RedisStore

The following code:

    store: new RedisStore({
      client: redis
    }),

will cause Typescript to fail with error:

'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.ts(7009)

from connect-redis.

wavded avatar wavded commented on August 23, 2024

Hmmm.. I cannot duplicate that error with your repo locally. The errors go away when I add new. That error makes me think you have still have the legacy @types/connect-redis installed or cached somehow.

from connect-redis.

hvqzao avatar hvqzao commented on August 23, 2024

No, I've tested it with fresh repo (I've commited the change replacing store: RedisStore({ with store: new RedisStore({:

git clone https://github.com/hvqzao/cr-701 connect-redis-issue
cd connect-redis-issue
npm install -E
npm start

tsc gives slightly different error than VSCode:

image

from connect-redis.

wavded avatar wavded commented on August 23, 2024

Screenshot 2023-04-10 at 1 48 05 PM

Following your steps on a fresh checkout I get the following errors, this is due to it missing the @types/node @types/express and @types/express-session in the package.json. However, if I install those there, I get no errors:

Screenshot 2023-04-10 at 1 51 07 PM

from connect-redis.

hvqzao avatar hvqzao commented on August 23, 2024

That didn't work on my side. I'm facing this issue on multiple projects / environments / workstations. Do you have connect-redis linked locally on your workstation via npm link?

from connect-redis.

wavded avatar wavded commented on August 23, 2024

No link locally (I wondered the same earlier and double checked). I am running this against the published 7.0.1 release and have tried on multiple environments as well with the same result. Hmm... have you been able to replicate on say a Docker container or something so we could try the same environment? Wish I could be of more help here...

from connect-redis.

hvqzao avatar hvqzao commented on August 23, 2024

Thanks for your time. I must say I see such thing for the first time. This repo works on one workstation, but results in error mentioned above on another ¯_(ツ)_/¯. Same version of node is used. I tried to reboot, remove ~/.npm, remove package-lock, node_modules, reinstall deps. The funny thing is that when vscode complains, npm start also complains. If it works in one, it works in both. I will keep looking into that. Or future release of connect-redis will solve the feature automagically just bacause of version bump.

from connect-redis.

jackey8616 avatar jackey8616 commented on August 23, 2024

@hvqzao I have same issue, but solve with removed @types/connect-redis.
I saw there is no @types/connect-redis install in your repo.
Maybe you accidentally installed it?

from connect-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.