redis.expireTime() returns relative TTL seconds on live host instead of Unix timestamp seconds

Open Beginner friendly
#307 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
redis, typescript
Domain
backend, databases

Research direction

Start by tracing the live host implementation of redis.expireTime() and compare it with redis.d.ts and RedisMock in @devvit/test. Verify whether the live path incorrectly maps ExpireTime to TTL, then add or update coverage for absolute Unix expiration timestamps against the mock. The work is done when live and mocked redis.expireTime() return the same absolute timestamp semantics and the repro no longer returns 60 or 59.

Written by the indexing model from the issue text.

Description

In @devvit/redis (0.15.6), redis.expireTime(key) behaves differently between the live Devvit runtime and both its TypeScript documentation and RedisMock.

Expected (per redis.d.ts and standard Redis EXPIRETIME):
The JSDoc states:

Returns the absolute Unix timestamp (since January 1, 1970) in seconds at which the given key will expire.

RedisMock in @devvit/test follows this and returns an absolute Unix timestamp in seconds (e.g. 1796474880).

Actual on live Devvit (0.15.6):
Calling redis.expireTime(key) right after redis.expire(key, 60) returns the remaining relative TTL in seconds (60, then 59 on a follow-up read) instead of a Unix timestamp.

Minimal repro:

await redis.set('probe:ttl', '1');
await redis.expire('probe:ttl', 60);
const exp = await redis.expireTime('probe:ttl');
console.log({ exp, nowSec: Math.floor(Date.now() / 1000) });
// RedisMock (@devvit/test): exp is ~nowSec + 60 (Unix timestamp)
// Live Devvit 0.15.6 host: exp is 60 (or 59) — relative TTL seconds

Why this bites in practice:
Any code comparing expireTime(key) against Date.now() / 1000 (e.g. checking whether a lock or daily state key is about to roll over) passes under @devvit/test and then reads 60 < 1796... as already expired in production. It looks like the host plugin is wiring ExpireTime to TTL rather than EXPIRETIME (or the JSDoc and RedisMock need to match if relative TTL is intentional).

Dominant language
TypeScript
Stars
217
Forks
89
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reddit/devvit

All issues in reddit/devvit

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.