React 应用程序 CodeShip-Heroku 部署:初始构建中断并出现 503 错误代码

React app CodeShip-Heroku deployment: initial build breaks with 503 error code

我正在使用 CodeShip 和 Heroku 部署我的 React 前端。我可以打开应用程序,但 CodeShip 显示构建已损坏,原因如下:

Trying (1 of 6) 'wget --no-check-certificate --output-document=/dev/null http://******.herokuapp.com'
--2020-03-11 21:59:01--  http://******.herokuapp.com/
Resolving ******.herokuapp.com (******.herokuapp.com)... 52.214.138.78, 54.77.242.148, 54.171.40.67, ...
Connecting to ******.herokuapp.com (******.herokuapp.com)|52.214.138.78|:80... connected.
HTTP request sent, awaiting response... 503 Service Unavailable
2020-03-11 21:59:35 ERROR 503: Service Unavailable.

但是当我打开根 url 后检查我的 Heroku 日志时,我得到了这个,其中 none 个是 Error 503

2020-03-11T22:12:59.322877+00:00 heroku[router]: at=info method=GET path="/" host=******.herokuapp.com request_id=57f74e93-a951-4179-ae00-3761976d2656 fwd="176.63.10.67" dyno=web.1 connect=0ms service=3ms status=304 bytes=173 protocol=https
2020-03-11T22:12:59.389496+00:00 heroku[router]: at=info method=GET path="/sockjs-node" host=******.herokuapp.com request_id=516c3825-2bc9-4dfd-a4b9-7a84d2b40bf4 fwd="176.63.10.67" dyno=web.1 connect=1ms service=32093ms status=101 bytes=129 protocol=https
2020-03-11T22:12:59.475750+00:00 heroku[router]: at=info method=GET path="/static/js/0.chunk.js" host=******.herokuapp.com request_id=ab42c365-d66e-4439-be0a-525f425ebec5 fwd="176.63.10.67" dyno=web.1 connect=0ms service=32ms status=304 bytes=176 protocol=https
2020-03-11T22:12:59.476304+00:00 heroku[router]: at=info method=GET path="/static/js/main.chunk.js" host=******.herokuapp.com request_id=a78e6524-3792-42d6-8fab-760aa27aea3b fwd="176.63.10.67" dyno=web.1 connect=1ms service=32ms status=304 bytes=174 protocol=https
2020-03-11T22:12:59.451102+00:00 heroku[router]: at=info method=GET path="/static/js/bundle.js" host=******.herokuapp.com request_id=9e4977bc-ab8e-4cd5-8500-b3ebc411feaa fwd="176.63.10.67" dyno=web.1 connect=0ms service=5ms status=304 bytes=174 protocol=https
2020-03-11T22:12:59.793691+00:00 heroku[router]: at=info method=GET path="/manifest.json" host=******.herokuapp.com request_id=3b248e90-9da2-472a-9653-f0d25f840d76 fwd="176.63.10.67" dyno=web.1 connect=1ms service=6ms status=304 bytes=237 protocol=https
2020-03-11T22:12:59.809653+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=******.herokuapp.com request_id=7dab8f56-c457-42a1-a190-37f8a0a687fd fwd="176.63.10.67" dyno=web.1 connect=1ms service=21ms status=200 bytes=9780 protocol=https

我的 React 代码中的 '/' 根路径 returns:

//App.js
<PublicRoute exact path='/' component={Home} layout={LandingLayout} />

//PublicRoute.js
const PublicRoute = ({ component: Component, layout: Layout, ...rest }) => (
    <Route {...rest} render={props => (
        <Layout>
            <Component {...props} />
        </Layout>
    )}
    />
);

//Home.js
import React, { Component } from 'react';

export default class Home extends Component {
  static displayName = Home.name;

  render () {
    return (
      <div>
      </div>
    );
  }
}

我该如何解决这个问题?

平淡无奇的答案有点令人难过: 我正在使用 heroku 的免费版本,这可能会导致应用程序启动时资源较少并且变得更慢。

如果达到也 it seems that all heroku application build process has 30 seconds timeout limit which sends back an H12 Request timout 错误。

如果我在 -----> Build succeeded! 消息从 Heroku 记录到 CodeShip 后立即手动继续调用应用程序,由于某些随机原因我会得到更快的响应,并且在这种情况下构建不会中断。

正如您在图片上看到的,这是我在之前的构建中所做的。出于测试目的,我再次重新启动构建并且没有手动打开应用程序。达到 30 秒超时,构建已中断。

再试一次,不断刷新 heroku 应用程序 url 它确实再次发回了 200 OK 代码。

Trying (1 of 6) 'wget --no-check-certificate --output-document=/dev/null http://******.herokuapp.com'
--2020-03-14 14:59:15--  http://******.herokuapp.com/
Resolving ******.herokuapp.com (******.herokuapp.com)... 34.255.174.179, 52.18.75.143, 52.208.237.242, ...
Connecting to ******.herokuapp.com (******.herokuapp.com)|34.255.174.179|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1700 (1.7K) [text/html]
Saving to: /dev/null

阅读 heroku 文档很明显,没有关于如何处理此问题的确切答案。应用程序的长循环或繁重的计算需求很容易导致 30 秒超时。

无论如何,我的应用程序相当轻量级,没有严格的逻辑,只有 React 本身的大量依赖。这种方式的自动交付并不多,所以我将联系 Heroku 并尝试找出它是否真的是免费版本的问题。

编辑:

原来 Heroku 不为免费用户提供任何支持,他们将您重定向到 whosebug.com:

我猜圆圈是完整的。