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: Add a timer that holds the event loop open while there are pending calls #1580

Merged

Conversation

murgatroid99
Copy link
Member

This should fix #1579.

We want to hold the event loop open as long as there is an active call. For most of the lifetime of most calls, this is accomplished by refing each subchannel as long as it is handling at least one active call. However, that does not account for calls that are never attached to subchannels. This closes that gap by creating an interval timer that lasts for the lifetime of the channel. We ref that timer as long as there is at least one pending call on the channel that has not been assigned to a subchannel.

@@ -230,6 +239,14 @@ export class ChannelImplementation implements Channel {
new MaxMessageSizeFilterFactory(this.options),
new CompressionFilterFactory(this),
]);

this.callRefTimer = setInterval(() => {}, 1 << 31 - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a maxint constant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is Number.MAX_SAFE_INTEGER, but it's larger than that, and Number.MAX_VALUE, which is even larger.

@@ -230,6 +239,14 @@ export class ChannelImplementation implements Channel {
new MaxMessageSizeFilterFactory(this.options),
new CompressionFilterFactory(this),
]);

this.callRefTimer = setInterval(() => {}, 1 << 31 - 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, that's not even the only package that provides a noop function. We used to depend on one of them.

@murgatroid99 murgatroid99 changed the base branch from master to @grpc/grpc-js@1.1.x September 17, 2020 20:43
@murgatroid99 murgatroid99 merged commit b51afd3 into grpc:@grpc/grpc-js@1.1.x Sep 17, 2020
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

Successfully merging this pull request may close these issues.

On slow Internet connection, node process exists before response returned by gRPC
3 participants