Skip to content

NestJS Microservice: response.status is not a function #16051

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

Open
3 tasks done
vahidvdn opened this issue Apr 14, 2025 · 7 comments · May be fixed by #16066
Open
3 tasks done

NestJS Microservice: response.status is not a function #16051

vahidvdn opened this issue Apr 14, 2025 · 7 comments · May be fixed by #16066
Assignees
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK

Comments

@vahidvdn
Copy link

Is there an existing issue for this?

How do you use Sentry?

Self-hosted/on-premise

Which SDK are you using?

@sentry/nestjs

SDK Version

9.2.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. Use a microservice like MQTT and register an event in the controller (@MessagePattern('yourtopic'))
  2. Create a Guard
  3. Register it globally
  4. Return false inside the guard (it means rejecting the request)
  5. Publish a message to your topic
  6. Then you see the error

Expected Result

App should be able to continue its job without any error.

Actual Result

I get this error:

TypeError: response.status is not a function
    at ExpressAdapter.reply (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/platform-express/adapters/express-adapter.js:28:22)
    at SentryGlobalFilter.handleUnknownError (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/core/exceptions/base-exception-filter.js:46:28)
    at SentryGlobalFilter.catch (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/core/exceptions/base-exception-filter.js:17:25)
    at SentryGlobalFilter.catch (/Users/vahid/casenio/dnw/tdk-api/node_modules/@sentry/nestjs/src/setup.ts:110:49)
    at RpcExceptionsHandler.invokeCustomFilters (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/microservices/exceptions/rpc-exceptions-handler.js:34:32)
    at RpcExceptionsHandler.handle (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/microservices/exceptions/rpc-exceptions-handler.js:17:36)
    at RpcProxy.handleError (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/microservices/context/rpc-proxy.js:24:34)
    at /Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/microservices/context/rpc-proxy.js:17:29
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ServerMqtt.handleEvent (/Users/vahid/casenio/dnw/tdk-api/node_modules/@nestjs/microservices/server/server.js:85:32)

Node.js v22.2.0
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 14, 2025
@github-actions github-actions bot added the Package: nestjs Issues related to the Sentry Nestjs SDK label Apr 14, 2025
@chargome
Copy link
Member

Hey @vahidvdn!

Can you confirm that this issue is caused by the Sentry SDK? If so would you mind sharing a minimal reproduction repo?

@vahidvdn
Copy link
Author

Hey @chargome

Please check the minimal reproduction repo here

The steps to reproduce are mentioned in the README. Please let me know if you need anything else.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 14, 2025
@chargome chargome self-assigned this Apr 15, 2025
@chargome
Copy link
Member

@vahidvdn So the issue is that our exception handler does not handle rpc contexts, you can follow the PR above and once it is released use SentryRpcFilter in your app. Thanks for the repro and for reporting this!

@vahidvdn
Copy link
Author

vahidvdn commented Apr 15, 2025

@chargome Sounds good! Thank you.
There are also more contexts, Ws is a built-in context and Graphql can also be a context. Is there any support for those contexts as well?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 15, 2025
Copy link
Member

For graphql yes, for ws not yet!

@vahidvdn
Copy link
Author

@chargome One more question, my app is a hybrid app. So, I have both http context and rpc context (in this case mqtt). After you released a new version, which filter do I need to use? Does it support such a case?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 15, 2025
@chargome
Copy link
Member

@vahidvdn with the change you can then add both filters, as the SentryGlobalFilter will skip handling rpc contexts – I'll update the docs accordingly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants