-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.17.0
Plugin version
No response
Node.js version
Irrelevant
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Irrelevant
Description
The type of genReqId server option implies its only argument is an instance of FastifyRequest:
genReqId?: <...>(req: FastifyRequest<...>) => string,However, in practice it is given RawRequest (e.g. http.IncomingMessage):
function routeHandler (req, res, params, context, query) {
const id = genReqId(req)while FastifyRequest is created only later in this function.
Steps to Reproduce
To reproduce, let's extend the test in test/genReqId.js:
genReqId: function (req) {
t.hasProp(req, 'id')
t.hasProp(req, 'raw')
return 'a'
}This test will now fail, because these two props normally found in FastifyRequest instance do not actually exist. (Well, id value is supposed to be provided by genReqId in the first place)
Expected Behavior
The type definition should be something like this:
genReqId?: <...>(req: RawRequest) => string,Reactions are currently unavailable