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

オープン 初心者向け
#307 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
redis, typescript
領域
backend, databases

調査の方向性

まず redis.expireTime() のライブホスト実装を追い、@devvit/test の redis.d.ts と RedisMock と比較します。ライブ経路が ExpireTime を誤って TTL にマッピングしていないかを確認し、その後、モックに対する絶対 Unix 有効期限タイムスタンプのテストカバレッジを追加または更新します。ライブ版とモック版の redis.expireTime() が同じ絶対タイムスタンプのセマンティクスを返し、再現ケースが 60 や 59 を返さなくなったら作業完了です。

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
TypeScript
スター
217
フォーク
89
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

reddit/devvit のほかの issue

reddit/devvit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。