Skip to content

usage reporting failing with following stacktrace (core v0.8.3) #6359

Closed
@tomasstrejcek

Description

@tomasstrejcek

POST https://app.graphql-hive.com/usage failed (7ms). The "listener" argument must be of type function. Received an instance of Object"}
TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object"}
at checkListener (node:events:275:3)"}
at ClientRequest.once (node:events:652:3)"}
at new ClientRequest (node:_http_client:248:10)"}
at request (node:https:381:10)"}
at /usr/app/node_modules/@opentelemetry/instrumentation-http/build/src/http.js:513:41"}
at safeExecuteInTheMiddle (/usr/app/node_modules/@opentelemetry/instrumentation/build/src/utils.js:28:18)"}
at /usr/app/node_modules/@opentelemetry/instrumentation-http/build/src/http.js:505:78"}
at AsyncLocalStorage.run (node:internal/async_local_storage/async_hooks:91:14)"}
at SentryContextManager.with (/usr/app/node_modules/@opentelemetry/context-async-hooks/build/src/AsyncLocalStorageContextManager.js:33:40)"}
at SentryContextManager.with (file:///usr/app/node_modules/@sentry/node/node_modules/@sentry/opentelemetry/build/esm/index.js:1475:24)"}

our implementation:

const hive = createHive({
    enabled: isStaging || isProd,
    debug: isTest || isDevelopment,
    token: config.get<string>('hive.token'),
    usage: {
      exclude: ['sentry_healthcheck'],
      clientInfo(context: MercuriusContext): any {
        const name = context.reply.request.headers['apollographql-client-name']
        const version = context.reply.request.headers['apollographql-client-version']

        if (name && version && typeof name === 'string' && typeof version === 'string') {
          return { name, version }
        }

        return null
      }
    },
    agent: {
      logger: {
        info: (str: string) => {
          logger.info({ str }, 'hive info log')
        },
        error: (str: string, obj: any) => {
          logger.fatal({ obj, str }, 'hive error log')
        }
      }
    }
  })

secondary issue is that the error is passed to the logger so each line is logged separatelny but that i can live with :)

overall usage is still present in the app, but i see few of these errors in the past few days

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