Skip to content

[BUG] RedisAdapter.hasKey() always returns true - missing await on client.exists() #683

Description

@Priyanshubhartistm

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

  1. Enable payments in .nostr/settings.yaml
  2. Send any event from an admitted pubkey
  3. Observe that hasKey always returns true regardless of cache state

System: Linux, Docker


Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions