类型错误:无法在 NodeJs (fastify) 部署上将 undefined 或 null 转换为对象

我正在尝试在 Linux 服务器上部署 NodeJs 项目(fastify 框架)。问题是在为每个请求部署它后,它返回 500 错误,错误如下:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at _Reply.Reply.headers (/data/backend/node_modules/fastify/lib/reply.js:245:23)
    at Object.getallServices (/data/backend/controller/esb.js:5762:21)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

我知道将空参数传递给函数时会返回此错误,但函数和数据没有问题,因为它可以在我的本地服务器(Windows)上正常运行。 我认为 fastify 库有问题,因为错误包含它的文件。我还在 /data/backend/node_modules/fastify/lib/reply.js 文件中看到,并且没有使用过的 Function.keys 或类似的东西。我也将 fastify 库更新到最新版本,没有任何变化。

我在我的代码中使用 try catch 在到达这一行之前 res.status(200).headers().send({ "key": "value" }) 一切看起来都还好我的功能运行正常。

zjd1987zjd 回答:类型错误:无法在 NodeJs (fastify) 部署上将 undefined 或 null 转换为对象

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/5690.html

大家都在问