Skip to content

using demand control raises "TypeError: Invalid value used as weak map key" on startup #1607

@n1ru4l

Description

@n1ru4l

Using the following gateway config with the docker container causes crash upon startup.

gateway.config.ts

export const gatewayConfig = defineConfig({
  demandControl: {
    maxCost: 1000,
    includeExtensionMetadata: true,
  },
});
docker run --name hive-gateway --rm -p 4000:4000 --volume $(pwd)/gateway.config.ts:/gateway/gateway.config.ts \
  ghcr.io/graphql-hive/gateway:2.1.10 \
  proxy https://api.graphql-hive.com/graphql
2025-10-14T12:03:03.083Z INF Starting Hive Gateway 2.1.10 in proxy mode
2025-10-14T12:03:03.084Z INF Found default config file /gateway/gateway.config.ts
2025-10-14T12:03:03.188Z INF Loaded config
2025-10-14T12:03:03.193Z INF Loading schema
  endpoint: "https://api.graphql-hive.com/graphql"
2025-10-14T12:03:03.200Z ERR
  stack: "TypeError: Invalid value used as weak map key
      at WeakMap.set (<anonymous>)
      at memoized (file:///node_modules/.chunk/index-C__xks22.mjs:42:27)
      at onSubgraphExecute (file:///node_modules/.chunk/getGraphQLWSOptions-qgIqzKlJ.mjs:67717:29)
      at file:///node_modules/.chunk/getGraphQLWSOptions-qgIqzKlJ.mjs:34630:13
      at handleCallback (file:///node_modules/.chunk/index-BjsbKlRC.mjs:94:20)
      at Promise.then (file:///node_modules/.chunk/index-BjsbKlRC.mjs:31:40)
      at handleMaybePromise (file:///node_modules/.chunk/index-BjsbKlRC.mjs:10:33)
      at iterate (file:///node_modules/.chunk/index-BjsbKlRC.mjs:93:16)
      at handleCallbackResult (file:///node_modules/.chunk/index-BjsbKlRC.mjs:102:20)
      at Promise.then (file:///node_modules/.chunk/index-BjsbKlRC.mjs:31:40)"
  message: "Invalid value used as weak map key"
  name: "TypeError"
  class: "TypeError"

When commenting out the demandControl configuration, everything works as expected. It seems like it is only supported in the supergraph mode right now.

However, the documentation does not mention this limitation at all: https://the-guild.dev/graphql/hive/docs/gateway/other-features/security/demand-control. In addition to that I also think demand control should work in proxy mode.

Metadata

Metadata

Assignees

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