treblle-node icon indicating copy to clipboard operation
treblle-node copied to clipboard

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

Open Calisto184AC0 opened this issue 1 year ago • 3 comments

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

Calisto184AC0 avatar Jun 12 '24 14:06 Calisto184AC0

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

JustSteveKing avatar Jun 13 '24 08:06 JustSteveKing

Hi, I am looking into this.

nikme avatar Jun 13 '24 13:06 nikme

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".

nikme avatar Jun 24 '24 14:06 nikme

@Calisto184AC0 v2 is out with much better support for path blocking

cindreta avatar Aug 13 '25 13:08 cindreta