fastify / process-warning Goto Github PK
View Code? Open in Web Editor NEWA small utility for creating warnings and emitting them.
License: MIT License
A small utility for creating warnings and emitting them.
License: MIT License
The time has long passed for a v1.0.0 release. We really shouldn't be shipping major, non-RC, versions of Fastify with 0.y.z
dependencies; especially not dependencies we control.
If I would need to implement this function I would implement it differently. E.g. calling warning.emit('XYZ') makes it necessary to lookup the existing warnings.
From the API usage I would do it like this:
const warning = require('process-warning')()
const FSTWRN001 = warning.create('FastifyWarning', 'FSTWRN001', 'The %s schema for %s: %s is missing. This may indicate the schema is not well specified.', { unlimited: true })
FSTWRN001.emit()
Basically, due to this piece of code:
Line 94 in c0649f8
The last created warning decides wether all the created warnings are limited or unlimited. Thus in fastify, since last created warning is made unlimited:
https://github.com/fastify/fastify/blob/99a405a4e347629595ac5062c74d91675b1b34e5/lib/warnings.js#L58
warning.create('FastifyWarning', 'FSTWRN002', 'The %s plugin being registered mixes async and callback styles, which will result in an error in `fastify@5`', { unlimited: true })
All the declared warnings are spamming the application :)
Should either move opts inside "create" or add a new hashmap for the unlimited flag
After the rename to process-warning, I plan to deprecate fastify-warning.
The main dependents of this module are:
I'll deprecate fastify-warning as soon as those are migrated.
No response
No response
I am running into an issue using typescript, fastify, and jest.
A plugin I am using is throwing a FastifyWarning.
Jest blows up with:
TypeError [ERR_INVALID_ARG_TYPE]: The "warning" argument must be of type string or an instance of Error. Received an instance of FastifyWarning
at process.emitWarning (internal/process/warning.js)
It should be possible to disable warnings per environment variable, e.g. PROCESS_WARNING_DISABLE=1, or maybe specify which warnings to disable, e.g. PROCESS_WARNING_DISABLE=FSTDEP018,FSTDEP015
It could be useful to disable process warnings, especially now that we are deprecating more and more functionality in fastify v4.
If we would decide to allow specifying which warnings should not be emitted anymore, then a dev could be empowered to "acknowledge" the warning and realize that there is a potential technical debt, but maybe does not want to solve the warning immediatly.
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.