Skip to main content

警告

目录

¥Table of contents

警告

¥Warnings

Fastify 中的警告

¥Warnings In Fastify

Fastify 使用 Node.js 的 警告事件 API 通知用户已弃用的功能和编码错误。Fastify 的警告可以通过 FSTWRNFSTDEP 前缀识别。遇到此类警告时,强烈建议使用 --trace-warnings--trace-deprecation 标志确定原因。它们会生成指向应用代码中发生问题的位置的堆栈跟踪。由于缺乏详细信息,没有此信息的警告问题将被关闭。

¥Fastify uses Node.js's warning event API to notify users of deprecated features and coding mistakes. Fastify's warnings are recognizable by the FSTWRN and FSTDEP prefixes. When encountering such a warning, it is highly recommended to determine the cause using the --trace-warnings and --trace-deprecation flags. These produce stack traces pointing to where the issue occurs in the application's code. Issues opened about warnings without this information will be closed due to lack of details.

也可以禁用警告,但不建议这样做。如有必要,请使用以下方法之一:

¥Warnings can also be disabled, though it is not recommended. If necessary, use one of the following methods:

  • NODE_NO_WARNINGS 环境变量设置为 1

    ¥Set the NODE_NO_WARNINGS environment variable to 1

  • --no-warnings 标志传递给节点进程

    ¥Pass the --no-warnings flag to the node process

  • NODE_OPTIONS 环境变量中设置 no-warnings

    ¥Set no-warnings in the NODE_OPTIONS environment variable

有关禁用警告的更多信息,请参阅 Node 的文档

¥For more information on disabling warnings, see Node's documentation.

禁用警告可能会在升级 Fastify 版本时导致问题。只有经验丰富的用户才应考虑禁用警告。

¥Disabling warnings may cause issues when upgrading Fastify versions. Only experienced users should consider disabling warnings.

Fastify 警告代码

¥Fastify Warning Codes

CodeDescriptionHow to solveDiscussion
FSTWRN001The specified schema for a route is missing. This may indicate the schema is not well specified.Check the schema for the route.#4647
FSTWRN002The %s plugin being registered mixes async and callback styles, which will result in an error in fastify@5.Do not mix async and callback style.#5139

Fastify 弃用代码

¥Fastify Deprecation Codes

Node.js CLI 选项支持弃用代码:

¥Deprecation codes are supported by the Node.js CLI options:

代码描述怎么解决讨论