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

grpc-js: A channel that never connects keeps the process alive #767

Closed
murgatroid99 opened this issue Mar 7, 2019 · 4 comments
Closed
Assignees

Comments

@murgatroid99
Copy link
Member

If a channel is trying to connect and it never succeeds and never gets closed by the user, it appears to keep the process alive, even if there are no active calls. This differs from the behavior of the other library, which only keeps the process alive with an active call or other pending asynchronous action from the point of view of the surface API.

@murgatroid99 murgatroid99 self-assigned this Mar 7, 2019
@murgatroid99
Copy link
Member Author

Update: It looks like what is keeping the process alive is alternately the connection we are trying to establish and the backoff timer.

@murgatroid99
Copy link
Member Author

This can be fixed by unrefing timers as long as there are no pending calls on the channel. That change should probably wait until the upcoming connection logic changes as part of the load balancer support.

@ThomWright
Copy link
Contributor

This might be what is preventing my tests from finishing. I have some tests which launch the pubsub emulator and send/receive some messages using it.

The tests used to pass and exit fine. I have updated the pubsub library like so, which starts using @google/grpc-js in favour of grpc:

-    "@google-cloud/pubsub": "^0.28.1",
+    "@google-cloud/pubsub": "^0.30.1",

My tests now hang. Using wtfnode I see:

[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
  - fd 1 (tty) (stdio)
  - fd 2 (tty) (stdio)
- Timers:
  - (500 ~ 500 ms) (anonymous) @ myproject/__tests__/test.ts:13
  - (2782 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2546 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2777 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2420 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2996 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2716 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2285 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125
  - (2985 ~ 2 s) (anonymous) @ myproject/node_modules/google-gax/node_modules/@grpc/grpc-js/build/src/channel.js:125

The first timer for 500ms is my own, to make sure I can see the grpc timers. The grpc timers all seem to be doing an exponential backoff, and are keeping my process alive.

This is a blocker for me. I'd really like to update @google-cloud/pubsub to resolve this issue: googleapis/nodejs-pubsub#574 - but now my tests don't pass.

I assume this is the same issue. If not, I can make a new issue. Thanks!

@murgatroid99
Copy link
Member Author

I believe this is fixed as of version 0.6.x.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants