VulcanJS / Vulcan

🌋 A toolkit to quickly build apps with React, GraphQL & Meteor
http://vulcanjs.org
MIT License
7.98k stars 1.89k forks source link

GraphQL socket hang up randomly -> Page change to blank screen for 2 or 3 s before revert to normal #1899

Closed adalidda closed 6 years ago

adalidda commented 6 years ago

Hi,

I use Vulcan 1.8.9 with forum package.

I notice something strange. For unknown reasons, sometime, the current page change to blank screen for 2 or 3 s before revert back to normal.

That happen, randomly, and every where: home page, post page, home page listed by category, etc...

This issue is happen only since Vulcan 1.8.9. I don't see it in Vulcan 1.8.5 and before.

As my database is the same as the version 1.8.5 (using 3 replicasets), I suspect that this issue is related to the new version of GraphQL or the new version of Meteor (1.6.1).

Any suggestion on how to avoid it ?

Thank You Adalidda

adalidda commented 6 years ago

When I debug, I got the following error message:

Firefox can’t establish a connection to the server at wss://adalidda.net/sockjs/162/cr2quapq/websocket. The connection to wss://adalidda.net/sockjs/162/cr2quapq/websocket was interrupted while the page was loading. Firefox can’t establish a connection to the server at wss://adalidda.net/sockjs/434/jxtvgl74/websocket.
The connection to wss://adalidda.net/sockjs/434/jxtvgl74/websocket was interrupted while the page was loading

TypeError: s is undefined Stack trace: x<.node_modules.meteor["vulcan:i18n"].lib.modules["message.js"]/c/<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:115:1738 A.forEach@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:71:996 x<.node_modules.meteor["vulcan:i18n"].lib.modules["message.js"]/c@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:115:1712 Ct/<.beginWork@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1179688 o@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1192254 a@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1192575 s@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1192813 E@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1196353 _@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1196090 h@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1195219 d@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1194609 wt/a.enqueueForceUpdate@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:1169659 i<.node_modules.react.cjs["react.production.min.js"]/o.prototype.forceUpdate@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:244723 o/a</u.prototype.forceRenderChildren@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:749973 o/a</u.prototype.subscribeToQuery/t@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:749487 o/a</u.prototype.subscribeToQuery/n@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:749570

i<.node_modules["apollo-client"]["apollo.umd.js"]/</gt</n.prototype.setUpQuery/t.error/<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:797715 i<.node_modules["apollo-client"]["apollo.umd.js"]/</gt</n.prototype.setUpQuery/t.error@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:797675 i<.node_modules["apollo-client"]["apollo.umd.js"]/</Ct</t.prototype.queryListenerForObserver/<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:811021 i<.node_modules["apollo-client"]["apollo.umd.js"]/</Ct</t.prototype.broadcastQueries/</<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:820008 i<.node_modules["apollo-client"]["apollo.umd.js"]/</Ct</t.prototype.broadcastQueries/<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:819974 i<.node_modules["apollo-client"]["apollo.umd.js"]/</Ct</t.prototype.broadcastQueries@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:819892 i<.node_modules["apollo-client"]["apollo.umd.js"]/</Ct</t.prototype.fetchQuery/w<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:9:810290 n.bindEnvironment/<@https://adalidda.net/5eb684bc1b0fcab3f6e719d8703c323bdacd13d9.js?meteor_js_resource=true:1:7876


It seem that the errors are due to:

  1. websocket
  2. apollo query
  3. vulcan:i18n package

but why it's happen randomly ?

Thank You Adalidda

SachaG commented 6 years ago

You can try running your dev environment in production mode with the --production flag, maybe that'll help track down the issue?

SachaG commented 6 years ago

(Assuming this only happens in production mode. If it happens in dev too, what's the error there?)

adalidda commented 6 years ago

The error is cause by socket hang up randomly: request to http://localhost:3000/graphql failed , reason socket hang up

It seem that the error is related to Node 8, see it here https://github.com/nodejs/node/issues/13461

I don't know how to fix it and why it happen randomly ?

Thank You SachaG Adalidda

SachaG commented 6 years ago

What's your OS?

adalidda commented 6 years ago

My servers are on Ubuntu 16.10 (GNU/Linux 4.8.0-59-generic x86_64) CPU: Intel xeon E5-2620v3 with 10 cores RAM: 50 GB RAM

Node 8.9.3

My MongoDB is set with 3 replicaset (2 with Percona In-memory engines and 1 with WiredTiger engine) with the following setting "MONGO_URL": "mongodb://user:password@ip1:32015,ip2:32015,ip2:32016/ADA2018A?authSource=admin&replicaSet=perconamix&readPreference=nearest&w=majority", "MONGO_OPLOG_URL": "mongodb://user:password@ip1:32015,ip2:32015,ip2:32016/local?authSource=admin&replicaSet=perconamix"

I use Nginx version 1.12.2 to load balance my Vulcan App within the 5 Upstream servers

Now I have identified the issue: it's the web socket that close randomly for unknown reason.

Thank You SachaG

adalidda commented 6 years ago

The issue is related to PM2. By upgrading to PM2 latest on my servers, I am now able to deploy in cluster_mode and the issues are gone.

Thank You

SachaG commented 6 years ago

Great, good to know :)

On Sat, Feb 17, 2018 at 2:43 PM, Adalidda notifications@github.com wrote:

The issue is related to PM2. By upgrading to PM2 latest on my servers, I am now able to deploy in cluster_mode and the issues are gone.

Thank You

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/VulcanJS/Vulcan/issues/1899#issuecomment-366418943, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV5sOC7BGOqCJ4seskCtoXk1LS8b7dQks5tVmb6gaJpZM4SBagm .