google-api-nodejs-client icon indicating copy to clipboard operation
google-api-nodejs-client copied to clipboard

Gaxios Adapter is not used in http2 client

Open alexnederlof opened this issue 2 years ago • 1 comments

Environment details

  • OS: MacOs
  • Node.js version: v18
  • npm version:
  • googleapis version: 109.0.1

Steps to reproduce

  1. Add an adapter through the GaxiosOptions to the client, and enable http2 in those same options.
  2. Observe that the adapter is not used
  3. Set http2 to false
  4. Observe the adapter is now called

You can also see from the source, the adapter function is not called https://github.com/googleapis/nodejs-googleapis-common/blob/97a581b74b549dbe8a4156a772316c7cbc23af7a/src/http2.ts#L162, even though it's present int the options.

alexnederlof avatar Dec 18 '22 12:12 alexnederlof

Apologies for the delay in getting around to looking at this. It looks like setting http2 branches the path here. When HTTP2 is not in use the authClient or DefaultTransporter are used. Both of these ultimately use Gaxios under the hood for HTTP calls. Gaxios will call an adapter if one is provided.

However, when http2 = true the code winds up here. In this case the calls is handled by clienthttp2session which is provided by Node. Obviously, this would not know how to use a Gaxios provided adapter.

I think the confusion stems from using GaxiosOptions all over the place when not all code paths utilize Gaxios under the hood for calls on the wire.

ddelgrosso1 avatar Sep 13 '23 15:09 ddelgrosso1

Probably best to reopen this as a feature request to reduce the usage of GaxiosOptions in multiple contexts.

ddelgrosso1 avatar Feb 28 '24 22:02 ddelgrosso1