google-api-nodejs-client
google-api-nodejs-client copied to clipboard
Gaxios Adapter is not used in http2 client
Environment details
- OS: MacOs
- Node.js version: v18
- npm version:
googleapisversion:109.0.1
Steps to reproduce
- Add an adapter through the
GaxiosOptionsto the client, and enablehttp2in those same options. - Observe that the adapter is not used
- Set
http2tofalse - 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.
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.
Probably best to reopen this as a feature request to reduce the usage of GaxiosOptions in multiple contexts.