Describe the bug
hasKey() in src/adapters/redis-adapter.ts wraps the Redis EXISTS call in Boolean() without awaiting the promise, meaning it always returns true (a non-null Promise is truthy).
// src/adapters/redis-adapter.ts:52
public async hasKey(key: string): Promise<boolean> {
await this.connection
debug('has %s key', key)
return Boolean(this.client.exists(key)) // ← Promise object, always truthy!
}
Expected behavior
Should return true only when the key actually exists in Redis.
Impact
The method is currently commented-out in event-message-handler.ts precisely because it doesn't work:
// const hasKey = await this.cache.hasKey(`${event.pubkey}:is-admitted`)
// TODO: use cache
This forces a full Postgres lookup on every event from every authenticated user, causing unnecessary DB load.
To Reproduce
- Enable payments in
.nostr/settings.yaml
- Send any event from an admitted pubkey
- Observe that
hasKey always returns true regardless of cache state
System: Linux, Docker
Describe the bug
hasKey()insrc/adapters/redis-adapter.tswraps the RedisEXISTScall inBoolean()withoutawaiting the promise, meaning it always returnstrue(a non-null Promise is truthy).Expected behavior
Should return
trueonly when the key actually exists in Redis.Impact
The method is currently commented-out in
event-message-handler.tsprecisely because it doesn't work:This forces a full Postgres lookup on every event from every authenticated user, causing unnecessary DB load.
To Reproduce
.nostr/settings.yamlhasKeyalways returnstrueregardless of cache stateSystem: Linux, Docker