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

App crashes because of network error when Apollo Subscription Server is added #11641

Open
kizim opened this issue Sep 23, 2021 · 11 comments
Open

App crashes because of network error when Apollo Subscription Server is added #11641

kizim opened this issue Sep 23, 2021 · 11 comments

Comments

@kizim
Copy link

@kizim kizim commented Sep 23, 2021

Meteor app crashes when GraphQL Subscription Server is added to the app.

The app — https://github.com/kizim/meteor-apollo-server-webapp-bug:

  • Meteor 2.3
  • Apollo Server 3.3.0
  • Subscription Server imported from subscriptions-transport-ws@0.9.19
  • macOS 11.1

The problem first appeared after upgrading Meteor from version 2.2.3 to 2.3.
I think a possible reason could be an update to the webapp package: #11224.
On request to any route except http://localhost:3000/graphql and ws://localhost:3000/graphql the server crashes:

throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}

How to reproduce:

  1. Start the app by running meteor command.
  2. Run any GraphQL operation: http://localhost:3000/graphql. For example: { links { title } } - it works as expected as well as GraphQL subscriptions (mutation test triggers demo subscription).
  3. Open any other route or send any request (http or ws) - the server will crash.

The problem only exist when SubscriptionServer is enabled and WebApp.httpServer used as a server:
https://github.com/kizim/meteor-apollo-server-webapp-bug/blob/master/server/graphql.js

const subscriptionServer = SubscriptionServer.create({
  schema,
  execute,
  subscribe,
}, {
  server: WebApp.httpServer,
  path: server.graphqlPath,
});
@renanccastro
Copy link
Contributor

@renanccastro renanccastro commented Sep 23, 2021

Thanks for the detailed description and reproduction, we are checking it right now.

@renanccastro
Copy link
Contributor

@renanccastro renanccastro commented Sep 23, 2021

I can't repro @kizim
Here are the steps I did:

Nothing crashed my server.
Is there any step I'm missing?

@kizim
Copy link
Author

@kizim kizim commented Sep 23, 2021

@renanccastro thanks, you did everything right.

I just ran the commands rm -rf node_modules && npm i, meteor reset and started the app. Opened http://localhost:3000/ and the server crashed. Here's the screen recording:

meteor-crash.mov

@kolyasya
Copy link

@kolyasya kolyasya commented Sep 23, 2021

@renanccastro pulled the repo, npm install & npm start — got the same issue as @kizim

@StorytellerCZ
Copy link
Contributor

@StorytellerCZ StorytellerCZ commented Sep 23, 2021

Don't forget to add meteor before npm install => meteor npm i

@StorytellerCZ
Copy link
Contributor

@StorytellerCZ StorytellerCZ commented Sep 23, 2021

Tested as well and was unable to reproduce. Everything works fine for me. Both on Meteor 2.3 and 2.4. I'm on Ubuntu.

@renanccastro
Copy link
Contributor

@renanccastro renanccastro commented Sep 23, 2021

It does indeed crash on Mac OSX, but not on my Linux machine.

@renanccastro
Copy link
Contributor

@renanccastro renanccastro commented Sep 24, 2021

@kizim I'm still investigating, but can you try to run your server on mac with:

DISABLE_WEBSOCKETS=false meteor

and let me know if it stops crashing?

@kizim
Copy link
Author

@kizim kizim commented Sep 27, 2021

@renanccastro with DISABLE_WEBSOCKETS=false HTTP requests are now handled correctly, but the problem still exists for WS requests.

meter-ws-crash.mov

@filipenevola
Copy link
Member

@filipenevola filipenevola commented Sep 27, 2021

@kizim this error is happening only in Node.js 14 (that is the version of Node.js starting on Meteor 2.3) so this is where the problem started. Also only in MacOS so it seems to be related to MacOS + Node.js 14.

But so far we didn't identify exactly what is causing it and how to fix it.

About your last video, is this crash affecting you? Because in your video it seems that you made this request just to prove a point but I would like to know if this is still affecting you developing your app.

@kizim
Copy link
Author

@kizim kizim commented Sep 28, 2021

@filipenevola this issue does not affect our application, because as we found out it only occurs in macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants