-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
(node:8) [FSTDEP019] FastifyDeprecation #992
Comments
Did you search for |
Thank you Eomm, Can see reference like : reply?.context?.schema?.description in cade base (around 7hits) Any suggestion how to over come these deprecated messages ? (node:8) [FSTDEP019] FastifyDeprecation: reply.context property access is deprecated. Please use "reply.routeOptions.config" or "reply.routeOptions.schema" instead for accessing Route settings. The "reply.context" will be removed in as we are seeing lot of such error messages, intern this causing huge logs for my server. |
It is possible to provide a Maybe that would help |
@metcoder95 FYR log mdm-doer > 2024-03-08T03:27:32.850Z [info]: Started <8223f4e9-ef4a-4ff5-9fb1-f511806fd8c6>: GET /cl-doer/api/life-line │
mdm-doer > 2024-03-08T03:27:32.851Z [info]: IP <8223f4e9-ef4a-4ff5-9fb1-f511806fd8c6>: 10.10.17.6 User-Agent : Other 0.0.0 / Other 0.0.0 │
mdm-doer > /cl-doer/api/life-line path │
mdm-doer > 2024-03-08T03:27:32.866Z [info]: Ended <8223f4e9-ef4a-4ff5-9fb1-f511806fd8c6>: GET /cl-doer/api/life-line 200 - 15.773136138916016 │
mdm-doer > (node:96) [FSTDEP019] FastifyDeprecation: reply.context property access is deprecated. Please use "reply.routeOptions.config" or │ respective controller code of that life-line API const { HealthChecker } = require('./life-line');
class LifeLineController {
static async perform(request, reply) {
const result = await HealthChecker.perform();
if (result?.isDiskHealthy) {
reply.code(200);
} else {
reply.code(503);
}
reply.header('Content-Type', 'application/json; charset=utf-8');
reply.send(result);
}
}
module.exports = LifeLineController; hook for request logger. const fp = require('fastify-plugin');
const { v4: uuid } = require('uuid');
const useragent = require('useragent');
module.exports = fp(async (fastify, opts) => {
const apiRequestId = uuid();
fastify.addHook('onRequest', (request, reply, done) => {
const requestIp = request.ip;
const userAgent = useragent.parse(request.headers['user-agent']).toString();
logger.info(`Started <${apiRequestId}>: ${request.method} ${request.url}`);
logger.info(`IP <${apiRequestId}>: ${requestIp} User-Agent : ${userAgent}`);
done();
});
fastify.addHook('preHandler', async (request) => {
console.log(request.url, 'path');
if (['PUT', 'POST', 'PATCH'].includes(request.method) && !request.url.includes('cl-auth')) {
logger.info(`Ended <${apiRequestId}>: ${JSON.stringify(request.body)}`);
}
});
fastify.addHook('onResponse', (request, reply, done) => {
const responseTime = reply.getResponseTime();
logger.info(`Ended <${apiRequestId}>: ${request.method} ${request.url} ${reply.statusCode} - ${responseTime} ms`);
done();
});
fastify.addHook('onError', async (request, reply, error) => {
reply.code(500);
})
}); |
We are on GitHub and not on stackoverflow. Provide a link to a github repo with the mvce so that each maintainer doesnt need to rebuild your example. |
|
Seeing deprecation issues as pointed by FSTDEP019
https://fastify.dev/docs/latest/Reference/Warnings/#FSTDEP019
(node:8) [FSTDEP019] FastifyDeprecation
here message
(node:8) [FSTDEP019] FastifyDeprecation: reply.context property access is deprecated. Please use "reply.routeOptions.config" or "reply.routeOptions.schema" instead for accessing Route settings. The "reply.context" will be removed in
fastify@5
.Context
fastify current version - 4.26.0
Tried disabling by these but no luck.
passing the --no-warnings flag to the node process
setting 'no-warnings' in the NODE_OPTIONS environment variable
any suggestion how to over come these deprecated messages ?
The text was updated successfully, but these errors were encountered: