koajs / koajs/session

Issue when setting maxAge = 'session'

Open
#203 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
908
Forks
115
PR merge metrics
No merged PRs in 30d

Description

Everything is fine when I set maxAge to a number.

As soon as I set `maxAge` to `"session"` I get a REDIS error:

```
ReplyError$1: ERR value is not an integer or out of range
```

I have launched my app with redis traces:
```
DEBUG=ioredis:* node app/server.js
```

And I see the error at this point:
```
ioredis:redis write command[35.224.153.24:18918]: 0 -> setex('ee336b93-7195-4e06-9e66-dffedbda5466,session,{"grant":{"provider":"google","dynamic":{"x":"151","y":"26"},"state":"98709c21509fd43b0c2ec39071816bebaf0f4368","nonce":"9de36d71dfba5d70310464eee0c4f3a486 ... ') +8s
```

This is how I setup the session:
```
app
.use(
session(
{
store: redisStore({
host: redisUrl.hostname,
port: Number(redisUrl.port),
password: redisUrl.password,
}),
maxAge: 'session',
key: 'flyxc.sess',
httpOnly: true,
signed: true,
rolling: false,
renew: false,
secure: process.env.NODE_ENV != 'development',
},
app,
),
)
```

Any clue what could go wrong or how to debug further ?

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue using the app/server.js setup and the session configuration shown in the report. Trace how maxAge: "session" reaches the Redis setex call, then verify the behavior with regression coverage; done means the configuration no longer produces an invalid Redis TTL.

Written by the indexing model from the issue text.

Assessment

Tech stack
redis, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.