Skip to content
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

[FSTDEP004] FastifyDeprecation #3284

Closed
2 tasks done
siemah opened this issue Aug 29, 2021 · 7 comments
Closed
2 tasks done

[FSTDEP004] FastifyDeprecation #3284

siemah opened this issue Aug 29, 2021 · 7 comments
Labels
typescript TypeScript related wontfix This will not be worked on, the behavior is intended

Comments

@siemah
Copy link
Contributor

siemah commented Aug 29, 2021

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure it has not already been reported

Fastify version

3.20.2

Plugin version

3.0.0

Node.js version

12.22.3

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

10.15.7

Description

I tried to call preParsing hook using the async way as suggested in the documentation:

fastify.addHook('preParsing', async (request, reply, payload) => {
  // Some code
  return payload;
})

and when i take a look at my terminal i found this warning:

(node:37541) [FSTDEP004] FastifyDeprecation: You are using the legacy preParsing hook signature. Use the one suggested in the documentation instead.
server listening on http://[::1]:4321

then i tried the other way:

fastify.addHook('preParsing',  (request, reply, payload, done) => {
  // Some code
  return done(null, payload);
})

i didnt find any warning.

Steps to Reproduce

  • Create a fastify server
  • Add preParsing hook using the code above

Expected Behavior

No response

@climba03003
Copy link
Member

I cannot reproduce your problem.
https://replit.com/@climba03003/fastify-issue-3284

@climba03003 climba03003 added the need info More information is needed to resolve this issue label Aug 30, 2021
@siemah
Copy link
Contributor Author

siemah commented Aug 30, 2021

Hey @climba03003 check this code for the server.ts:

import fastify from 'fastify';

const server = fastify();

server.register(async(app) => {
  app.addHook('preParsing', async(req, rep,pay) => {
    console.log('here from "preParsing" hook')
    return pay;
  })
  app.get('/warning', async(req, rep) => {
    return {
      hello: "hola"
    }
  })
})
server.listen(3000)

and this is package.json

{
  "dependencies": {
    "fastify": "^3.20.2",
    "fastify-plugin": "^3.0.0",
    "fastify-sequelize": "^1.0.4",
    "mysql2": "^2.3.0",
    "pino-pretty": "^6.0.0"
  },
  "devDependencies": {
    "@tsconfig/node12": "^1.0.9",
    "@types/node": "^16.7.1",
    "nodemon": "^2.0.12",
    "ts-node": "^10.2.1",
    "typescript": "^4.3.5"
  },
  "scripts": {
    "dev": "nodemon src/server.ts",
    "build": "tsc -p tsconfig.json"
  }
}

Note:

This warning printted when i use fastify with ts-node and typescript

@climba03003
Copy link
Member

@siemah
I cannot reproduce it by using TypeScript.
image

@siemah
Copy link
Contributor Author

siemah commented Aug 31, 2021

@climba03003
I create this repos to produce the same warning i got

@climba03003
Copy link
Member

climba03003 commented Aug 31, 2021

It should be the TypeScript transpile problem.

We test the function against AsyncFunction constructor and your target is es5 which do not have AsyncFunction.
I will mark it as wontfix as we do not have any other good way to test it.

Change the target greater than es2017 will solve the issue

@climba03003 climba03003 added wontfix This will not be worked on, the behavior is intended typescript TypeScript related and removed need info More information is needed to resolve this issue labels Aug 31, 2021
@siemah
Copy link
Contributor Author

siemah commented Aug 31, 2021

@climba03003
I think the documentation need to be updated to inform devs to update target to "es2017" after generating the tsconfig using npx tsc --init

@climba03003
Copy link
Member

@climba03003
I think the documentation need to be updated to inform devs to update target to "es2017" after generating the tsconfig using npx tsc --init

@siemah Feel free to send a PR for the documentation improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript TypeScript related wontfix This will not be worked on, the behavior is intended
Projects
None yet
Development

No branches or pull requests

3 participants