0

当我处于开发模式时一切正常,现在当我将我的应用程序上传到 heroku 时,我不断收到这个错误,它唯一说的是Request timeout.

heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/visited/posts" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https

但我不知道我超时的原因,因为它在开发中工作正常。可能与我在免费测功机上的事实有关?

到目前为止,我所做的是在我支持的异步中发出所有请求,但我仍然收到错误消息。它发生在几个端点上。

例子

const Comment = require('../../models/Comment');

exports.getComments = async (req, res) => {
    await Comment
        .find({ postId: req.params.postid })
        .populate('author')
        .exec((error, comments) => {
            if (!comments) {
                return res.status(404).json({
                    message: 'No comments found for this post',
                });
            }

            if (error) {
                return res.json({ message: error.message, });
            }

            res.status(200).json({ 
                comments,
            });
    })
};
4

0 回答 0