0

我正在尝试部署位于此处的 api graphql
=> https://github.com/DimiMikadze/create-social-network
但我遇到了一些问题并且页面仍然是空白的。(前端部署在 netlify)它在开发模式下工作。 我想知道付费帐户是否可以解决这个问题。我不确定是因为我的免费 heroku 帐户和 dyno 限制或 heroku 问题还是生产部署损坏
它在这里工作 => https://worldexplorer.netlify.app/
已添加配置变量而没有 PORT,我应该如果它在heroku上是动态的,还添加PORT?我的第二个猜测是替换函数 ws,http 到 ws,https。我已经检查了所有内容,但仍然失败。我已将 useUnifiedTopology 添加到 mongoose.connect() 仍然无法正常工作。有什么建议么 ?

错误 H12,使用 SIGTERM 停止所有进程,进程以状态 143 退出,dyno=web.1 connect=0ms service=30000ms status=503

全面审查 heroku 日志 -t

2020-06-12T10:44:56.446529+00:00 heroku[web.1]: Restarting
2020-06-12T10:44:59.369642+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-06-12T10:45:01.534501+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-06-12T10:45:01.535655+00:00 app[web.1]: server ready at http://localhost:3044/graphql
2020-06-12T10:45:01.535782+00:00 app[web.1]: Subscriptions ready at ws://localhost:3044/graphql
2020-06-12T10:45:01.586325+00:00 app[web.1]: DB connected
2020-06-12T10:45:03.055672+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T10:45:03.169058+00:00 heroku[web.1]: Process exited with status 143
2020-06-12T10:45:06.816310+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-06-12T10:45:06.817765+00:00 app[web.1]: server ready at http://localhost:3844/graphql
2020-06-12T10:45:06.817908+00:00 app[web.1]: Subscriptions ready at ws://localhost:3844/graphql
2020-06-12T10:45:06.883664+00:00 app[web.1]: DB connected
2020-06-12T10:45:07.327247+00:00 heroku[web.1]: State changed from starting to up
2020-06-12T10:45:12.038980+00:00 app[api]: Set MAIL_USER config vars by user cichy96@gmail.com
2020-06-12T10:45:12.038980+00:00 app[api]: Release v11 created by user cichy96@gmail.com
2020-06-12T10:45:13.562118+00:00 heroku[web.1]: Restarting
2020-06-12T10:45:13.575923+00:00 heroku[web.1]: State changed from up to starting
2020-06-12T10:45:14.564507+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T10:45:14.646488+00:00 heroku[web.1]: Process exited with status 143
2020-06-12T10:45:17.663370+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-06-12T10:45:24.976462+00:00 app[api]: Release v12 created by user cichy96@gmail.com
2020-06-12T10:45:24.976462+00:00 app[api]: Set MAIL_PASS config vars by user cichy96@gmail.com
2020-06-12T10:45:25.614269+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-06-12T10:45:25.614985+00:00 app[web.1]: server ready at http://localhost:59382/graphql
2020-06-12T10:45:25.615090+00:00 app[web.1]: Subscriptions ready at ws://localhost:59382/graphql
2020-06-12T10:45:25.667679+00:00 app[web.1]: DB connected
2020-06-12T10:45:25.697175+00:00 heroku[web.1]: State changed from starting to up
2020-06-12T10:45:26.107722+00:00 heroku[web.1]: Restarting
2020-06-12T10:45:26.119837+00:00 heroku[web.1]: State changed from up to starting
2020-06-12T10:45:27.911856+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T10:45:27.998867+00:00 heroku[web.1]: Process exited with status 143
2020-06-12T10:45:29.575354+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-06-12T10:45:36.721995+00:00 app[web.1]: (node:4) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-06-12T10:45:36.731164+00:00 app[web.1]: server ready at http://localhost:57681/graphql
2020-06-12T10:45:36.731169+00:00 app[web.1]: Subscriptions ready at ws://localhost:57681/graphql
2020-06-12T10:45:36.782607+00:00 app[web.1]: DB connected
2020-06-12T10:45:37.182011+00:00 heroku[web.1]: State changed from starting to up
2020-06-12T10:50:16.497620+00:00 heroku[router]: at=info method=GET path="/" host=qualityprotector.herokuapp.com request_id=043d81b7-80fe-46bb-a5e4-53860f1bc38d fwd="83.22.243.180" dyno=web.1 connect=2ms service=14ms status=404 bytes=505 protocol=https
2020-06-12T10:50:22.382324+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: JsonWebTokenError: jwt must be provided
2020-06-12T10:50:22.382358+00:00 app[web.1]: at Proxy.module.exports (/app/node_modules/jsonwebtoken/verify.js:53:17)
2020-06-12T10:50:22.382359+00:00 app[web.1]: at /app/utils/apollo-server.js:17:32
2020-06-12T10:50:22.382360+00:00 app[web.1]: at new Promise (<anonymous>)
2020-06-12T10:50:22.382361+00:00 app[web.1]: at checkAuthorization (/app/utils/apollo-server.js:16:10)
2020-06-12T10:50:22.382361+00:00 app[web.1]: at ApolloServer.context (/app/utils/apollo-server.js:45:28)
2020-06-12T10:50:22.382362+00:00 app[web.1]: at ApolloServer.<anonymous> (/app/node_modules/apollo-server-core/dist/ApolloServer.js:467:38)
2020-06-12T10:50:22.382362+00:00 app[web.1]: at Generator.next (<anonymous>)
2020-06-12T10:50:22.382363+00:00 app[web.1]: at fulfilled (/app/node_modules/apollo-server-core/dist/ApolloServer.js:5:58)
2020-06-12T10:50:22.382363+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-06-12T10:50:22.382956+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-06-12T10:50:22.384392+00:00 app[web.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-06-12T10:50:52.373293+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/graphql" host=qualityprotector.herokuapp.com request_id=c83cff9c-21ec-4a3f-a0e8-c4379571a39e fwd="83.22.243.180" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2020-06-12T10:50:52.734000+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=qualityprotector.herokuapp.com request_id=2106dcdb-db6c-4319-89d1-849c5d3c6dd4 fwd="83.22.243.180" dyno=web.1 connect=1ms service=4ms status=404 bytes=516 protocol=https
2020-06-12T10:58:47.000000+00:00 app[api]: Build started by user cichy96@gmail.com
2020-06-12T10:59:33.211085+00:00 app[api]: Release v13 created by user cichy96@gmail.com
2020-06-12T10:59:33.211085+00:00 app[api]: Deploy 1fccd247 by user cichy96@gmail.com
2020-06-12T10:59:34.584781+00:00 heroku[web.1]: Restarting
2020-06-12T10:59:34.598736+00:00 heroku[web.1]: State changed from up to starting
2020-06-12T10:59:35.000000+00:00 app[api]: Build succeeded
2020-06-12T10:59:35.928901+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T10:59:36.040285+00:00 heroku[web.1]: Process exited with status 143
2020-06-12T10:59:37.657728+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-06-12T10:59:45.461692+00:00 app[web.1]: server ready at http://localhost:26575/graphql
2020-06-12T10:59:45.462171+00:00 app[web.1]: Subscriptions ready at ws://localhost:26575/graphql
2020-06-12T10:59:45.521392+00:00 app[web.1]: DB connected
2020-06-12T10:59:45.619943+00:00 heroku[web.1]: State changed from starting to up
2020-06-12T11:00:47.664793+00:00 heroku[web.1]: Restarting
2020-06-12T11:00:47.680114+00:00 heroku[web.1]: State changed from up to starting
2020-06-12T11:00:49.169628+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T11:00:49.286154+00:00 heroku[web.1]: Process exited with status 143
2020-06-12T11:00:50.587728+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-06-12T11:00:56.856897+00:00 app[web.1]: server ready at http://localhost:51664/graphql
2020-06-12T11:00:56.859410+00:00 app[web.1]: Subscriptions ready at ws://localhost:51664/graphql
2020-06-12T11:00:56.907031+00:00 app[web.1]: DB connected
2020-06-12T11:00:57.279110+00:00 heroku[web.1]: State changed from starting to up
2020-06-12T11:01:34.264690+00:00 heroku[web.1]: Restarting
2020-06-12T11:01:34.278533+00:00 heroku[web.1]: State changed from up to starting
2020-06-12T11:01:35.229897+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T11:01:35.322805+00:00 heroku[web.1]: Process exited with status 143
2020-06-12T11:01:37.425699+00:00 heroku[web.1]: Starting process with command `node index.js`
2020-06-12T11:01:46.205694+00:00 app[web.1]: server ready at http://localhost:21876/graphql
2020-06-12T11:01:46.206253+00:00 app[web.1]: Subscriptions ready at ws://localhost:21876/graphql
2020-06-12T11:01:46.320655+00:00 heroku[web.1]: State changed from starting to up
2020-06-12T11:01:46.357976+00:00 app[web.1]: DB connected
2020-06-12T11:10:41.526938+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: JsonWebTokenError: jwt must be provided
2020-06-12T11:10:41.526946+00:00 app[web.1]: at Proxy.module.exports (/app/node_modules/jsonwebtoken/verify.js:53:17)
2020-06-12T11:10:41.526947+00:00 app[web.1]: at /app/utils/apollo-server.js:17:32
2020-06-12T11:10:41.526948+00:00 app[web.1]: at new Promise (<anonymous>)
2020-06-12T11:10:41.526948+00:00 app[web.1]: at checkAuthorization (/app/utils/apollo-server.js:16:10)
2020-06-12T11:10:41.526949+00:00 app[web.1]: at ApolloServer.context (/app/utils/apollo-server.js:45:28)
2020-06-12T11:10:41.526949+00:00 app[web.1]: at ApolloServer.<anonymous> (/app/node_modules/apollo-server-core/dist/ApolloServer.js:467:38)
2020-06-12T11:10:41.526950+00:00 app[web.1]: at Generator.next (<anonymous>)
2020-06-12T11:10:41.526950+00:00 app[web.1]: at fulfilled (/app/node_modules/apollo-server-core/dist/ApolloServer.js:5:58)
2020-06-12T11:10:41.526950+00:00 app[web.1]: at processTicksAndRejections (internal/process/task_queues.js:97:5)
2020-06-12T11:10:41.527095+00:00 app[web.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
2020-06-12T11:10:41.527237+00:00 app[web.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
2020-06-12T11:11:11.489296+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/graphql" host=qualityprotector.herokuapp.com request_id=e18fbbb6-1b40-4cd7-a9c1-d0a9acef05f5 fwd="83.22.243.180" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2020-06-12T11:35:59.484532+00:00 heroku[web.1]: Idling
2020-06-12T11:35:59.486103+00:00 heroku[web.1]: State changed from up to down
2020-06-12T11:36:00.878335+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-12T11:36:01.035761+00:00 heroku[web.1]: Process exited with status 143

CHROME CONSOLE OUTPUT - am assuming that Error is caused by heroku free account with dyno limit thats why WS lost connection.

Uncaught TypeError: Cannot read property 'replace' of undefined
    at Module.93 (index.js:22)
    at f ((index):1)
    at Object.66 (background.jpg:1)
    at f ((index):1)
    at a ((index):1)
    at Array.e [as push] ((index):1)
    at main.43d14637.chunk.js:1
4

1 回答 1

1

如果您仅部署了 graphql 服务器,则无法发出GET请求,/因为没有路由,并且GETon也/graphql被禁用。

NODE_ENV设置为 时production,GraphQL Playground(以及自省)作为生产最佳实践被禁用。

但默认情况下,herokuNODE_ENV设置为生产。要使用 GraphQL IDE 测试您的 graphql 服务器,请将其设置为development启用 Playground in production

您还可以使用像邮递员这样的 API 客户端来仅发出 POST 请求,/graphql而无需更改您的配置。

于 2020-06-12T22:51:34.297 回答