Secbone / koa-session2

Middleware for Koa2 to get/set session
MIT License
152 stars 30 forks source link

TypeError: store.getID is not a function #58

Open RobertPrediger opened 3 years ago

RobertPrediger commented 3 years ago

In version 2.2.10, there is an error.

In index.js there is a call with:

 id = await store.getID(24);

But in store.js the function getID is not a promise:

getID(length) {

Result is:

TypeError: store.getID is not a function
   at /opt/aplus/dev/server/node_modules/koa-session2/index.js:17:34
Secbone commented 3 years ago

@RobertPrediger what version of node do you use? I think the await keyword is compatible with the synchronization function.

RobertPrediger commented 3 years ago

@Secbone I am using 14.15.4

As a workaround, if I remove the await, it's working.

Secbone commented 3 years ago

@RobertPrediger Do you use a custom store object? I think if it is an async function problem, it will be failed at this line https://github.com/Secbone/koa-session2/blob/9ee7b2696f4f77bbaa354e3201952f754e98196e/index.js#L12-L14 before the getID function. 🤔