为什么我在Heroku上经常收到H12错误代码AKA 503状态代码?

时间:2020-06-09 12:36:14

标签: heroku mern http-status-code-503 request-timed-out

在开发模式下,一切正常,现在,当我将应用程序上载到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,
            });
    })
};

0 个答案:

没有答案