0

Everything works fine while I was in development mode and now when I uploaded my app to heroku I keep getting this error, and the only thing it says is that is a 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

But I dont know the reason I get timeout because it was working alright in development. Might have something to do with the fact that I am on a free dyno?

What I've done so far is to make all the requests in my backed async, but I still get the error. And it happens on several endpoints.

example

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,
            });
    })
};
code_dude
  • 951
  • 2
  • 15
  • 28
  • Show code how you are serving those endpoints. – Tin Nguyen Jun 09 '20 at 12:37
  • I added an example of how I fetch the comments on a post. I repeat that it works alright in development. And it is happening randomly, now it works but then it doesn't. And the Request timeout error always happens when I try to refresh any page. – code_dude Jun 09 '20 at 12:53
  • If it works in production but at a later time stops working then it's your app. We need the error log of that. – Tin Nguyen Jun 09 '20 at 12:59

0 Answers0