Skip to content

@envelop/response-cache-cloudflare-kv has mismatched types with useResponseCache plugin #2505

Open
@tiwaojo

Description

@tiwaojo

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a
    minimal reproduction available on
    Stackblitz.
    • Please install the latest @envelop/* packages that you are using.
    • Please make sure the reproduction is as small as possible.
  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

The response cache plugin for Cloudflare KV Store(@envelop/response-cache-cloudflare-kv). Is not working as expected. There seems to be an internal type mismatch which leads to the following error messages below:

Typescript error during development

Type '(ctx: { MY_KV_STORE: KVNamespace<string>; } & { waitUntil(promise: Promise<unknown>): void; }) => Cache' is not assignable to type 'Cache'.ts(2322)
index.d.ts(9, 5): The expected type comes from property 'cache' which is declared here on type 'UseResponseCacheParameter<YogaInitialContext>'
Runtime error
✘ [ERROR] ERR TypeError: cache2.get is not a function
      at responseWithSymbol
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:59)
      at _handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:6:24)
      at handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:19:16)
      at null.<anonymous>
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:28)
  ERR TypeError: cache2.get is not a function
      at responseWithSymbol
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:59)
      at _handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:6:24)
      at handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:19:16)
      at null.<anonymous>
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:28)


[wrangler:inf] POST /graphql 500 Internal Server Error (104ms)
✘ [ERROR] ERR TypeError: cache2.get is not a function

      at responseWithSymbol
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:59)
      at _handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:6:24)
      at handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:19:16)
      at null.<anonymous>
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:28)


✘ [ERROR] ERR TypeError: cache2.get is not a function

      at responseWithSymbol
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:59)
      at _handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:6:24)
      at handleMaybePromise
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected]/node_modules/@whatwg-node/promise-helpers/esm/index.js:19:16)
      at null.<anonymous>
  (file:///workspaces/response-cache-repoduction/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@graphql-yoga/plugin-response-cache/esm/index.js:101:28)

To Reproduce Steps to reproduce the behavior:

  1. Set up a project following the details here

Expected behavior

Expected the types to match

Environment:

  • OS: Debian GNU/Linux 12 (bookworm) via Docker(WSL)
  • NodeJS: v22.14.10
  • @envelop/* versions:
    • "@envelop/response-cache-cloudflare-kv": "^3.1.3"

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions