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

fix(node/http2): fixes to support grpc #20712

Merged
merged 19 commits into from
Oct 12, 2023

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Sep 27, 2023

This commit improves "node:http2" module implementation, by enabling
to use "options.createConnection" callback when starting an HTTP2 session.
This change enables to pass basic client-side test with "grpc-js/grpc" package.
Smaller fixes like "Http2Session.unref()" and "Http2Session.setTimeout()"
were handled as well.

Fixes #16647

@@ -264,7 +271,7 @@ export class Http2Session extends EventEmitter {
}

setTimeout(msecs: number, callback?: () => void) {
setStreamTimeout(this, msecs, callback);
setStreamTimeout.call(this, msecs, callback);
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes problems with setStreamTimeout that were happening before

@@ -340,6 +352,7 @@ function assertValidPseudoHeader(header: string) {

export class ClientHttp2Session extends Http2Session {
#connectPromise: Promise<void>;
#refed = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

This bit should address #16647

Comment on lines +398 to +410
ref() {
this.#refed = true;
if (this[kPollConnPromiseId]) {
core.refOp(this[kPollConnPromiseId]);
}
}

unref() {
this.#refed = false;
if (this[kPollConnPromiseId]) {
core.unrefOp(this[kPollConnPromiseId]);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Ditto #16647

ext/node/polyfills/http2.ts Outdated Show resolved Hide resolved
ext/node/polyfills/http2.ts Outdated Show resolved Hide resolved
ext/node/polyfills/internal_binding/tcp_wrap.ts Outdated Show resolved Hide resolved
ext/web/02_timers.js Outdated Show resolved Hide resolved
@bartlomieju bartlomieju marked this pull request as ready for review October 6, 2023 22:49
Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

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

LGTM

@bartlomieju bartlomieju enabled auto-merge (squash) October 12, 2023 13:09
@bartlomieju bartlomieju merged commit cee2211 into denoland:main Oct 12, 2023
13 checks passed
@bartlomieju bartlomieju deleted the grpc_createConnection branch October 12, 2023 21:36
bartlomieju added a commit that referenced this pull request Oct 12, 2023
This commit improves "node:http2" module implementation, by enabling
to use "options.createConnection" callback when starting an HTTP2
session.
This change enables to pass basic client-side test with "grpc-js/grpc"
package.
Smaller fixes like "Http2Session.unref()" and "Http2Session.setTimeout()"
were handled as well.

Fixes #16647
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.

Cannot unref() node http2 connections
2 participants