Treblle / treblle-node

The official Treblle SDK for NodeJS/ExpressJS/NestJS. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.
https://www.treblle.com/
MIT License
36 stars 4 forks source link

NestJS - When accessing a blacklistPaths path it throws error if there is a global filter #19

Open Calisto184AC0 opened 5 months ago

Calisto184AC0 commented 5 months ago

Expected result

When I use the blacklist key and a global filter, it does not throw any errors.

Description

When I try to access the path of the blacklist, I get the following error:

Error: Cannot set headers after they are sent to the client

This is my code:

// main.ts

const httpAdapterHost = app.get(HttpAdapterHost)
app.useGlobalFilters(new AllErrorsFilter(httpAdapterHost))

const constants = app.get(ConstantsService)
const expressInstance = app.getHttpAdapter().getInstance()

useNestTreblle(expressInstance, {
  apiKey: constants.TREBLLE_API_KEY,
  projectId: constants.TREBLLE_PROJECT_ID,
  blacklistPaths: ['v1/health']
})

But when I remove the global filter, the blacklist does work.

Info Version
Node v20.11.1
@nestjs/core v10.3.8
treblle v1.4.3
OS macOS 14.5
JustSteveKing commented 5 months ago

Hey @Calisto184AC0 thanks for pointing this out! I will ask @nikme or @Treblle/treblle-internal to have a look into this for you

nikme commented 5 months ago

Hi, I am looking into this.

nikme commented 4 months ago

Hi @Calisto184AC0, I have published new v1.5.0. I have managed to get the error and fixed it, as well as updated the naming, so please just take notice it is now "blocklistPaths".