Skip to content

TypeError: res.hasHeader is not a function #14348

@ChronoBoot

Description

@ChronoBoot

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.38

Framework Version

8.38

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://stackblitz.com/edit/nestjs-typescript-starter-n88xqr

This is not a runnable verison because stackblitz only support up to node 18 and my project is with node 22

Steps to Reproduce

Copy in local the files from the stackblizt.com

Then install and run
yarn install
yarn build
yarn debug

Go to http://localhost:5001/graphql
Do this query :

query {
  	findCoordsAddress
}

Expected Result

{
  "errors": [
    {
      "message": "",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "findCoordsAddress"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "SyntaxError",
          "    at FindPlaceResolver.findCoordsAddress (/src/find-place/find-place.resolver.ts:10:11)",
          "    at /node_modules/@nestjs/core/helpers/external-context-creator.js:69:29",
          "    at InterceptorsConsumer.transformDeferred (/node_modules/@nestjs/core/interceptors/interceptors-consumer.js:31:33)",
          "    at /node_modules/@nestjs/core/interceptors/interceptors-consumer.js:18:86",
          "    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)",
          "    at bound (node:async_hooks:238:16)",
          "    at Observable._subscribe (/node_modules/rxjs/src/internal/observable/defer.ts:55:15)",
          "    at Observable._trySubscribe (/node_modules/rxjs/src/internal/Observable.ts:244:19)",
          "    at /node_modules/rxjs/src/internal/Observable.ts:234:18",
          "    at Object.errorContext (/node_modules/rxjs/src/internal/util/errorContext.ts:29:5)"
        ],
        "nodes": [
          {
            "kind": "Field",
            "name": {
              "kind": "Name",
              "value": "findCoordsAddress",
              "loc": {
                "start": 4,
                "end": 21
              }
            },
            "arguments": [],
            "directives": [],
            "loc": {
              "start": 4,
              "end": 21
            }
          }
        ],
        "source": {
          "body": "{\n  findCoordsAddress\n}\n",
          "name": "GraphQL request",
          "locationOffset": {
            "line": 1,
            "column": 1
          }
        },
        "positions": [
          4
        ],
        "path": [
          "findCoordsAddress"
        ],
        "originalError": {}
      }
    }
  ],
  "data": null
}

Actual Result

{
  "errors": [
    {
      "message": "res.hasHeader is not a function",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "findCoordsAddress"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "TypeError: res.hasHeader is not a function",
          "    at Reply.getHeader (/node_modules/fastify/lib/reply.js:237:34)",
          "    at FastifyAdapter.reply (/node_modules/@nestjs/platform-fastify/adapters/fastify-adapter.js:191:26)",
          "    at SentryGlobalFilter.handleUnknownError (/node_modules/@nestjs/core/exceptions/base-exception-filter.js:46:28)",
          "    at SentryGlobalFilter.catch (/node_modules/@nestjs/core/exceptions/base-exception-filter.js:17:25)",
          "    at SentryGlobalFilter.catch (/node_modules/@sentry/nestjs/src/setup.ts:85:49)",
          "    at /node_modules/@sentry/node/src/integrations/tracing/nest/sentry-nest-instrumentation.ts:288:40",
          "    at /node_modules/@sentry/node/node_modules/@sentry/opentelemetry/src/trace.ts:50:15",
          "    at /node_modules/@sentry/core/src/utils/handleCallbackErrors.ts:25:26)",
          "    at /node_modules/@sentry/node/node_modules/@sentry/opentelemetry/src/trace.ts:49:34",
          "    at AsyncLocalStorage.run (node:async_hooks:346:14)"
        ],
        "nodes": [
          {
            "kind": "Field",
            "name": {
              "kind": "Name",
              "value": "findCoordsAddress",
              "loc": {
                "start": 4,
                "end": 21
              }
            },
            "arguments": [],
            "directives": [],
            "loc": {
              "start": 4,
              "end": 21
            }
          }
        ],
        "source": {
          "body": "{\n  findCoordsAddress\n}\n",
          "name": "GraphQL request",
          "locationOffset": {
            "line": 1,
            "column": 1
          }
        },
        "positions": [
          4
        ],
        "path": [
          "findCoordsAddress"
        ],
        "originalError": {}
      }
    }
  ],
  "data": null
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nestjsIssues related to the Sentry Nestjs SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions