Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: [CloudflareStorage] expiry sometimes is 59 which breaks KV API #133

Open
firtoz opened this issue Jan 5, 2025 · 0 comments
Open

bug: [CloudflareStorage] expiry sometimes is 59 which breaks KV API #133

firtoz opened this issue Jan 5, 2025 · 0 comments

Comments

@firtoz
Copy link

firtoz commented Jan 5, 2025

Example error:

✘ [ERROR] Error: KV PUT failed: 400 Invalid expiration_ttl of 59. Expiration TTL must be at least 60.

      at async Object.set
  (file:///home/frtn/WORK/2024/llm-ws/node_modules/@openauthjs/openauth/dist/esm/storage/cloudflare.js:12:7)
      at async Object.subject

Seems to be caused by:

  async set(key, value, expiry) {
      await options.namespace.put(joinKey(key), JSON.stringify(value), {
        expirationTtl: expiry ? Math.floor((expiry.getTime() - Date.now()) / 1000) : undefined
      });
    },

and

 function set(adapter, key, value, ttl) {
    const expiry = ttl ? new Date(Date.now() + ttl * 1000) : undefined;
    return adapter.set(encode(key), value, expiry);
  }

See also: https://developers.cloudflare.com/kv/api/write-key-value-pairs/#put-method

put() method

- `expirationTtl` is the number that represents when to expire the key-value pair in seconds from now. The minimum value is 60.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant