Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node crash when antoher normal moleculer node running #51

Closed
AruXc opened this issue Oct 25, 2019 · 3 comments
Closed

node crash when antoher normal moleculer node running #51

AruXc opened this issue Oct 25, 2019 · 3 comments

Comments

@AruXc
Copy link
Contributor

AruXc commented Oct 25, 2019

normal moleculer node

[2019-10-25T01:42:12.376Z] INFO  dev_aru/REGISTRY: Node 'onecare_aru' reconnected.
[2019-10-25T01:42:12.450Z] INFO  dev_aru/BROKER: Service(s) 'greeter' are available.
greeter load
[2019-10-25T01:42:18.396Z] WARN  dev_aru/REGISTRY: Node 'onecare_aru' disconnected.

moleculer-apollo-server node

[2019-10-25T01:42:09.848Z] INFO  onecare_aru/API: Register route to '/graphql'
[2019-10-25T01:42:09.902Z] INFO  onecare_aru/API:        * /graphql => <Function>
[2019-10-25T01:42:09.903Z] INFO  onecare_aru/API:        * /graphql/.well-known/apollo/server-health => <Function>
[2019-10-25T01:42:09.903Z] INFO  onecare_aru/API: 
[2019-10-25T01:42:09.904Z] INFO  onecare_aru/API: Register route to '/'
[2019-10-25T01:42:09.904Z] INFO  onecare_aru/API: 
[2019-10-25T01:42:09.908Z] INFO  onecare_aru/TRANSIT: Connecting to the transporter...
[2019-10-25T01:42:09.908Z] WARN  onecare_aru/TRANSPORTER: TCP Transporter is an EXPERIMENTAL transporter. Do NOT use it in production yet!
[2019-10-25T01:42:09.910Z] INFO  onecare_aru/TRANSPORTER: TCP server is listening on port 57942
[2019-10-25T01:42:09.916Z] INFO  onecare_aru/TRANSPORTER: UDP Multicast Server is listening on 10.65.13.127:4445. Membership: 239.0.0.0
[2019-10-25T01:42:09.917Z] INFO  onecare_aru/TRANSPORTER: UDP discovery started.
[2019-10-25T01:42:09.918Z] INFO  onecare_aru/TRANSPORTER: TCP Transporter started.
[2019-10-25T01:42:10.428Z] INFO  onecare_aru/REGISTRY: '$node' service is registered.
[2019-10-25T01:42:10.429Z] INFO  onecare_aru/API: 🚀 GraphQL server is available at /graphql
[2019-10-25T01:42:10.430Z] INFO  onecare_aru/REGISTRY: 'greeter' service is registered.
[2019-10-25T01:42:10.430Z] INFO  onecare_aru/API: API Gateway listening on http://0.0.0.0:4000
[2019-10-25T01:42:10.431Z] INFO  onecare_aru/REGISTRY: 'api' service is registered.
[2019-10-25T01:42:10.432Z] INFO  onecare_aru/BROKER: ServiceBroker with 3 service(s) is started successfully.
mol $ 
mol $ [2019-10-25T01:42:13.506Z] INFO  onecare_aru/API: => GET /
[2019-10-25T01:42:13.509Z] INFO  onecare_aru/API:    Call custom function in '     * /graphql => <Function>' alias
[2019-10-25T01:42:13.509Z] INFO  onecare_aru/API: ♻ Recreate Apollo GraphQL server and regenerate GraphQL schema...
[2019-10-25T01:42:13.575Z] WARN  onecare_aru/API: Headers have already sent. { url: '/', action: undefined }
[2019-10-25T01:42:13.908Z] INFO  onecare_aru/API: => POST /
[2019-10-25T01:42:13.922Z] INFO  onecare_aru/API:    Call custom function in '     * /graphql => <Function>' alias
[2019-10-25T01:42:13.945Z] INFO  onecare_aru/REGISTRY: Node 'dev_aru' reconnected.
[2019-10-25T01:42:16.908Z] INFO  onecare_aru/API: => POST /
[2019-10-25T01:42:16.909Z] INFO  onecare_aru/API:    Call custom function in '     * /graphql => <Function>' alias
[2019-10-25T01:42:16.909Z] INFO  onecare_aru/API: ♻ Recreate Apollo GraphQL server and regenerate GraphQL schema...


/Users/aru/Desktop/WanFang/onecare_server/node_modules/ws/lib/websocket.js:757
  websocket.readyState = WebSocket.CLOSING;
                       ^

TypeError: Cannot set property 'readyState' of undefined
    at Socket.socketOnClose (/Users/aru/Desktop/WanFang/onecare_server/node_modules/ws/lib/websocket.js:757:24)
    at Socket.emit (events.js:194:15)
    at TCP._handle.close (net.js:597:12)

I want to share RESTful services to moleculer-apollo node and when I running together that moleculer-apollo will crash. How can I fix it? THX

@Hugome
Copy link
Collaborator

Hugome commented Oct 25, 2019

Oh this is a funny one, i have the same.
This come from the ws project : websockets/ws#1564 & websockets/ws#1591.
ws is a dependency of https://github.com/apollographql/subscriptions-transport-ws but not updated (5.2.0 in subscriptions-transport-ws, but ws is in 7.2.0) i will suppose they have compatibility issues in subscriptions-transport-ws for missing 2 major versions.

The TL;DR : In some weird black magic cases the close event of the ws is called twice, but in the second time websocket is undefined because already deleted.

If you want a ugly fix, to wait their update : https://gist.github.com/Hugome/84fcf5c57ccb608b92c24a3773f97778
I just added a "if" on the close listener (https://gist.github.com/Hugome/84fcf5c57ccb608b92c24a3773f97778#file-websocket-js-L758) and you can remove the console.log in the else if these log annoy you.

@AruXc AruXc changed the title node crash when antoher mormal moleculer node running node crash when antoher normal moleculer node running Oct 25, 2019
@AruXc
Copy link
Contributor Author

AruXc commented Oct 25, 2019

yeah, I found that issue and searching the resolve and you are here! thank you
I just use your solution first, and waiting the dependency update

@buraktt
Copy link

buraktt commented Sep 11, 2020

for anyone running to this issue, there is an undocumented setting autoUpdateSchema. setting this to false prevents crash.

arash16 added a commit to arash16/moleculer-apollo-server that referenced this issue Mar 8, 2021
This causes socket listeners to close gracefully.
Fixes issues moleculerjs#51 and moleculerjs#74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants