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

未關閉 適合新手
#307 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
78/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
redis, typescript
領域
backend, databases

研究方向

首先追蹤 redis.expireTime() 的即時主機實作,並將其與 @devvit/test 中的 redis.d.ts 和 RedisMock 進行比較。驗證即時路徑是否錯誤地將 ExpireTime 對應至 TTL,然後針對 mock 新增或更新絕對 Unix 過期時間戳的測試涵蓋範圍。當即時版本與 mock 版本的 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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

reddit/devvit 的其他 Issue

查看 reddit/devvit 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。